PDA

View Full Version : PHP session Globals Off


earthman
01-21-2007, 07:41 AM
Hi all,

Can anyone just give a me a simple example of how to use sessions with globals off. Im familiar with the concept of sessions, but never used them.

All i want to do is pass 2 bits of info in a session as simply as possible using sessions.

Cheers

RDM
01-21-2007, 08:41 AM
//Start Session
session_start();
header("Cache-control: private");

//Set Session Variable
$_SESSION['name'] = 'foobar';

//Echo Session Variable
echo $_SESSION['name']

//Delete Session Variable
unset($_SESSION['name']);

//Delete Session
session_destroy();


To use the session, you MUST call the start session section on EVERY page that will use the session, even if you're deleting it.