Losing session data on browser close

Giganews Newsgroups
Subject: Losing session data on browser close
Posted by:  bgold12 (bgold…@gmail.com)
Date: Sat, 16 Aug 2008

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

Replies