Jump to content

[SOLVED] using php sessions on different webpages


LittleB

Recommended Posts

Hello,

 

I would like some help on how to create sessions that can be used on another webpage, I have a form to be filled by users and I want their answers to be carried to another webpage before they are inserted into the database. Could anybody help.

 

Thank you in advance!

At the start of every script you need to use this one line:

session_start();

 

To assign a session variable a value use it like this:

$SESSION['name']='Fred';

or

$SESSION['age']=35;

 

To read it use it like this:

echo 'Name is '.$_SESSION['name'];

 

To clear it:

unset($_SESSION['name']);

Many thanks for your replies!!!!!

 

After posting my question I realised where I went wrong, I viewed the second php page (where the variable is called) without viewing the first one (where variable is declared and set). I admit that was very silly of me and I am posting it in case someone else does what I did =-)

 

Thanks again!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.