LittleB Posted April 22, 2009 Share Posted April 22, 2009 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! Link to comment https://forums.phpfreaks.com/topic/155175-solved-using-php-sessions-on-different-webpages/ Share on other sites More sharing options...
Yesideez Posted April 22, 2009 Share Posted April 22, 2009 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']); Link to comment https://forums.phpfreaks.com/topic/155175-solved-using-php-sessions-on-different-webpages/#findComment-816298 Share on other sites More sharing options...
WolfRage Posted April 22, 2009 Share Posted April 22, 2009 Well you could just post your form to the next page. Don't forget to read the manual it has lots of information about sessions: http://us.php.net/manual/en/ref.session.php http://us.php.net/manual/en/function.session-start.php Link to comment https://forums.phpfreaks.com/topic/155175-solved-using-php-sessions-on-different-webpages/#findComment-816302 Share on other sites More sharing options...
LittleB Posted April 22, 2009 Author Share Posted April 22, 2009 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!! Link to comment https://forums.phpfreaks.com/topic/155175-solved-using-php-sessions-on-different-webpages/#findComment-816332 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.