php: Cookies: is it save for the cookie name to be the same as the session ID?

Hello Experts,

is it save for the cookie name to be the same as the session ID?
if not, why not?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
Because it is just plain confusing.  Why would you want to do that?  Every time you go to a site, you get a different 'session_id' so you would have a bunch of cookies with 'session_id's for names.
Ray PaseurCommented:
$_COOKIE is an array.  The names of the cookies are keys that point to values.  The names and values are created on the server by your programming, sent to the client browser with the setcookie() function, stored on the browser and returned to the server on subsequent HTTP requests, where they are preloaded into $_COOKIE for use by your PHP script.  Thus the server has taken the "stateless" http protocol and introduced a way of understanding and controlling the browser's state.

The usual name of a PHP session cookie is PHPSESSID.  You can change that. The usual value is something that looks like the md5() string, for example, 3b63f439eb5a296257f513b32348053b.  So if I understand your question correctly, you want to set a cookie with the name 3b63f439eb5a296257f513b32348053b.  As a professional programmer I think you might want to choose meaningful names for variables and keys.

I view this question like "Is it safe to give my my dog and my daughter the same name?"  You might be able to live with the consequences of a decision like that, or you might find that things did not work out very well.  Only time will tell.  In our household, we think of Bowser and Jennifer in different terms.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
epifanio67Author Commented:
great answer.. thank you expert..
really helped
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.