Excerpt from http://php.about.com/od/advancedphp/ss/php_sessions.htm:
So how will it know it’s me? Most sessions set a cookie on your computer to uses as a key… it will look something like this: 350401be75bbb0fafd3d912a1a1d5e54.
My question is, in PHP, how to generate a key (e.g., 350401be75bbb0fafd3d912a1a1d5e54) for a session cookie?
And when do we need such a key? Why not just set $_SESSION['color']='red' in the first page and retrieve in the second page with $_SESSION['color']?
Just call
session_start()for this. A key would be generated automaticallywhen session starts, to distinguish one user from another
This is the way sessions works. You are encouraged to do it this way. Who says you can’t do it?