When one page is accessed, I would like to start a session and store a session variable:
<?php
session_start();
$_SESSION['myvar']='myvalue';
?>
Then from another page, I would like to check if that session variable has been stored:
<?php
session_start();
echo("1");
if(isset($_SESSION['myvar']))
{
echo("2");
if($_SESSION['myvar'] == 'myvalue')
{
echo("3");
exit;
}
}
?>
This code does not work for me.
ini_get
). And the current session ID can be retrieved withsession_id
– Gumbo Mar 30 '11 at 16:59/var/php_sessions
exist and is it readable/writable by PHP? You can check that easily by browsing to that directory and looking for a file named sess_e92d1212a93e216e96523ff1e903ed41. – Gumbo Mar 30 '11 at 17:16