note 12231 deleted from ref.session by yohgaki
| From: | yohgaki@php.net | Date: | Sat, 19 Jan 2002 06:42:22 +0000 |
| Subject: | note 12231 deleted from ref.session by yohgaki | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25114@lists.php.net to get a copy of this message | ||
<p>It does not seem to be very easy to figure out how to get sessions working when you're
running with register_globals turned off (see, for instance, the thread starting at http://marc.theaimsgroup.com/?l=php-general&m=98537955003921&w=2
in the php general list). Here are the functions that I used to actually get them working (note
that I am also calling session_start() at the top of every page via an include)...
function set_session($varname, $value)
{
global $HTTP_SESSION_VARS;
$HTTP_SESSION_VARS[$varname] = $value;
}
function get_session($varname)
{
global $HTTP_SESSION_VARS;
return $HTTP_SESSION_VARS[$varname];
}
function del_session($varname)
{
global $HTTP_SESSION_VARS;
unset($HTTP_SESSION_VARS[$varname]);
}
function clear_session()
{
global $HTTP_SESSION_VARS;
session_start();
session_destroy();
$HTTP_SESSION_VARS = array();
}
Note that it seems to be sufficient just to call start_session and then use the HTTP_SESSION_VARS
array. Don't bother with any of the other session functions, especially session_register().
Therefore these functions are a little superfluous, but I think they make my code look a little
nicer.