So once the user is logged in, the session has been started. Once the session has been started, can I change the session variable value? For example, lets say
i have this variable:
Code: Select all
$_SESSION['a'] = $a;But once the user has been logged in, I change this value of $a to 0.
Once I have changed this value, session does not change the value. Even if I refresh the page, it still stays "1" when I echo it.
In order for to see the change, I have to log out and log back in.
Can some please help with how to update the session with new values from the table? I spent hours and hours finding this..haven't found a solution yet.
My login.php
Code: Select all
...
$result = mysql_query("SELECT `id`,`pwd`,`full_name`,`approved`,`user_level`,`session_id`,`start_time`,`end_time`,`a`,`b` FROM users WHERE
$user_cond
AND `banned` = '0'
") or die (mysql_error());
$num = mysql_num_rows($result);
// Match row found with more than 1 results - the user is authenticated.
if ( $num > 0 ) {
list($id,$pwd,$full_name,$approved,$user_level,$session_id,$start_time,$end_time,$a,$b) = mysql_fetch_row($result);
....
session_start();
session_regenerate_id (true);
$_SESSION['user_id']= $id;
$_SESSION['user_name'] = $full_name;
$_SESSION['user_level'] = $user_level;
$_SESSION['session_id'] = $session_id;
$_SESSION['start_time'] = $start_time;
$_SESSION['end_time'] = $end_time;
$_SESSION['a'] = $a;
$_SESSION['b'] = $b;
$_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
....once the user is logged in, myaccount.php:
Code: Select all
<?php
include 'dbc.php';
page_protect();
?>