Sessions with register_globals = off
| From: | Padraig Kitterick | Date: | Fri, 26 Apr 2002 19:16:03 +0000 |
| Subject: | Sessions with register_globals = off | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-94791@lists.php.net to get a copy of this message | ||
Am in need of help or I will loose my sanity!!! Im runnin Php 4.1.2 with
Apache 1.3.22 on Win32 with register_globals set to off. My script is as
follows:
<?
session_start();
$myVar = "Something";
$HTTP_SESSION_VARS["mySessionVar"] = $myVar;
?>
If I check the cookie, its completely empty. Now if I change this to:
<?
session_start();
$myVar = "Something";
session_register("myVar");
?>
the cookie now contains:
myVar|s:9:"Something";
This is annoying as everyhwhere I read about sessions, Im told that if
register_globals is off, I shouldnt use session_register(), all I need to do
is:
$HTTP_SESSION_VARS["myVar"] = $myVar;
or
$_SESSION["myVar"] = $myVar;
but neither work :(
Finally, if I want to change the value of $HTTP_SESSION_VARS["myVar"] and
carry that change over to the next page it doesnt work. For example, i have
registered the session variable $myVar as above and can read it using
$HTTP_SESSION_VARS["myVar"]. If I do:
$HTTP_SESSION_VARS["myVar"] = "Some other text";
then $HTTP_SESSION_VARS["myVar"] contains that text, but only for this
page! How do I use sessions then with register_globals = off???!!!