PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

An Introduction To PHP Sessions

How Do I Change The Value Of A Session Variable?

This is easily achieved by simply declaring the variable again like so. If page1.php sets the value of $_SESSION['foo'] to bar, the value can be changed by resetting it like:

Listing 9 page1.php
<?php
    $_SESSION['foo'] = 'newbar';
?>

It really is that simple.

In This Article