I'm beginning to think that session handling just doesn't work in PHP;
This is my script:
<?
function InitializeSession()
{
$HTTP_SESSION_VARS["logged"] = true;
}
InitializeSession();
echo $HTTP_SESSION_VARS["logged"];
echo $_logged;
?>
It prints NOTHING. Does anyone have any idea of what the hell is going on?
Session doesn't work in PHP
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
If you've got PHP 4.1 or above try (as Jim said):
If however you're using PHP 4.0.6 or below you might be able to do (this may not work cause it's flaky):
otherwise you're going to have to look into using session_register().
Mac
Code: Select all
session_start(); // you must have this at the top of the script
function InitializeSession()
{
$_SESSION['logged'] = true;
}
InitializeSession();
echo $_SESSION['logged'];Code: Select all
session_start(); //'cause you can't do sessions without it
function InitializeSession()
{
global $HTTP_SESSION_VARS; // you have to declare this global in order to use it
$HTTP_SESSION_VARS['logged'] = true;
}
InitializeSession();
echo $HTTP_SESSION_VARS['logged'];Mac
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK