Is it possible to change session variable value?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shwathi
Forum Newbie
Posts: 6
Joined: Mon Mar 15, 2004 12:29 am
Contact:

Is it possible to change session variable value?

Post 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.
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post 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
Post Reply