i have a little problem in my code. I am trying to store some variables in my session after a user has logged in and then i want to redirect the user to another site. I have replaced the correct variables with some testvalues, but can not figure out why this does not work.
the code of the login site is:
require_once ('SecureSessionHandler.class.php');
$session = new SecureSessionHandler('abcd');
$session->start();
$session->put("test", "test");
print_r($_SESSION);
if(isset($_POST['login']))
{
//check User
//login
$session->put("userlogin", 1);
header("location: index.php");
exit();
}
echo "<form action ='' method='POST'>";
echo "<label for='username'>Name: </label>";
echo "<input type='text' name='username'><br>";
echo "<label for='passwort'>Passwort: </label>";
echo "<input type='password' name='passwort'><br>";
echo "<input type='submit' name='login' value='Anmelden'>";
echo "</form>";
The print_r($_SESSION)
works just fine here, it displays "Array ( [test] => test )
".
The code of the second site is:
<?php
require_once 'SecureSessionHandler.class.php';
$session = new SecureSessionHandler('abcd');
$session->start();
//some stuff that is not relevant here
//check login
$userlogin = $session->get('userlogin');
print_r($_SESSION);
echo "<br>";
if($userlogin == 1)
{
//do stuff
}
Here the print_r($_SESSION)
displays "Array ( )
".
I have no idea why this is the case. I would really appreciate any help you guys can give me.