What's a Session?
In terms of time, a session is the amount of time
during which a user visits a site. In the programming world, a session is kind
of like a big blob that can hold all sorts of variables and values.
·
This blob has an identification
string, such as 940f8b05a40d5119c030c9c7745aead9.
·
This identification string is
automatically sent to the user when a session is initiated, in a cookie called PHPSESSID (accessible via $_COOKIE[PHPSESSID]).
·
On the server side, a matching
temporary file is created with the same name (940f8b05a40d5119c030c9c7745aead9).
When you attempt to retrieve a session variable, the sequence
goes something like this (say you're trying to get the value of $_SESSION[count]):
1.
The PHP parser gets the value of $_COOKIE[PHPSESSID] from the user cookie.
2.
The PHP parser finds a matching
temporary session file.
3.
Inside the session file, the PHP
parser looks for count and then finds its value (say, 76).
4.
$_SESSION[count]
is equal to 76.



No comments:
Post a Comment