Page 1 of 1

Is it possible to change session variable value?

Posted: Mon Mar 15, 2004 12:29 am
by shwathi
After setting the value of a session variable, will it be possible to change its value before the end of the session? If possible can I have a small example?

Shwathi.

Posted: Mon Mar 15, 2004 12:35 am
by andre_c
session variables work just like normal variables, only that they're superglobals, but you can change them just as you would with a normal variable

Code: Select all

$_SESSION['test_value'] = 'First Value';

echo $_SESSION['test_value'];  // prints First Value

$_SESSION['test_value'] = 'Second Value';

echo $_SESSION['test_value']; // prints Second Value