Re: Session variables

From: Date: Sat, 07 Feb 2009 12:41:26 +0000
Subject: Re: Session variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-287894@lists.php.net to get a copy of this message
Paul M Foster wrote:
I'm not too clear on HTTP headers, cookies, and such. So here are questions related to that. Let's say I generate a random number that I want the user to enter in a form. When I generate the number, I store it in a session variable ($_SESSION). When the user submits the form, I check the number they enter with what I've stored in the session variable. Since this session variable survives across page loads (assuming session_start() is appropriately called), how is it stored and recalled? Is it automatically stored as a cookie on the user's system? Or is it stored on the server? And how does a server "get" a cookie? Is it a separate request made by the server to the client? If the value I've asked the user for is *not* stored as a cookie, then is it passed as part of the HTTP submission or what? Thanks for any enlightenment on this. Paul
seeing as you're a voomer here's a very mini explanation session has an id a: session id is passed to a user in the http headers users client gets sessionid and stores it in a cookie users client sends cookie with sessionid in it back to website every page load b: on the server a small file is stored in a temp directory containing all the stuff you've stored in session the file is named with the session id when php recieves a request, with a cookie, with a session id in it, then it grabs the related server side session files, pulls the variables from it an makes them available to you in $_SESSION. v simple :p

« previous php.general (#287894) next »