Gazing into my crystal ball I observed bgold12 <bgold12@gmail.com>
writing in news:7f387b18-0f1e-46e7-807d-9fd3ea1da602@
8g2000hse.googlegroups.com:
Quote:
When a user logs onto my site, I set some session data using php:
>
...
session_start();
...
$_SESSION['key'] = 'value';
...
>
From what I understand, this should store the session data (i.e. the
key-value pairs) in a cookie on the user's computer, and it should be
valid until either I destroy the cookie or the user clears their
cookie data. This means that the user should be able to see that data
whenever they log back on the site, right?
>
And it works when the user leaves the site, and then comes back to it,
as long as they keep their browser open. But when the user closes
their browser, then I seem to lose that data (the cookie seems to
disappear). Why is this? Cookies aren't deleted when the browser is
closed, right?
>
Thanks,
>
bgold12
Sessions are for the _session_ - unlike a cookie which can be stored on
a user's computer and can be used at a later time (if the user accepts
cookies, and does not delete them on exit).
You can read the values in a cookie and put them into session variables.
For example, place a user name as a cookie, then read that value next
time the user comes in, request a password and store the password as a
session variable. When the user closes the browser, the cookie will
persist, but the password, which was held in a session variable, will be
destroyed.
--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share