Jump to content

Cookies


dalawh

Recommended Posts

I notice that you can check if a cookie is set or retrieve the information if you knew the name, but what happens if the name was dynamic (changing for each person)? Is there no way to retrieve it? Should the name always be dynamic?

Link to comment
Share on other sites

The $_COOKIE array is a normal array, so you can loop through it with a foreach loop to get the keys or use a function like array_keys to return an array of all of the keys, which will correspond to cookie names. http://www.php.net/m....array-keys.php
I just realized something... since the $_COOKIE array is a normal array, instead of using the names, couldn't I just use $_COOKIE[0] to get the value of the name. I know this is less accurate, but isn't that a possibility. Also, thanks for informing me of the array_keys.
Link to comment
Share on other sites

Guest So Called
I notice that you can check if a cookie is set or retrieve the information if you knew the name, but what happens if the name was dynamic (changing for each person)? Is there no way to retrieve it? Should the name always be dynamic?
I think it's excessive to give different users different cookie names, particularly when you can load up the contents with almost unlimited encryption schemes, and can use multiple cookies. I've spent a fair amount of time looking at the cookies stored on my computer and I've never noticed any sites that use different cookie names between users. (I've been admin on various forum sites, and wrote forum software for a while, so I've created multiple accounts for testing and I've looked at the code for at least one flavor forum software.) I don't see anything to be gained by giving different people different cookie names. The KISS principle says things should be no more complicated than they need be. Anything more complicated just takes more coding time, more debug time, and takes more labor if it needs to be maintained later.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...