PHP会话支持

I have never worked with sessions before so just need a bit of guidance. Some data from a form needs to be held whilst someone logs in. So I have got this far.

<?php
$_SESSION['tmp']['booking-form'] = array(
    'GT_title' => $SEStitle,
    'GT_actual_duration' => $SESactualduration,
    'SEScalstartdate' => $calstartdate,
    'GT_picture' => $picture,
    'GT_total_duration' => $SEStotalduration,
    'GT_total_dives' => $SEStotaldives,
    'GT_total_price' => $SEStotalprice,
    'GT_total_duration' => $SEStotalduration,
    'GT_specifications' => $SESspecifications
);
?>

Three questions.

  1. Where do I put this code as all the named fields in the array exist in a form towards the bottom of the page before the log in process begins.

  2. Is that all the code I need or do I need to put something else somewhere else.

  3. What do I do to call this session when the client has finished logging in and has been redirected to the booking area where I want this data to be called back up.

Wherever you want to use the session data, call session_start() at the top of any page before any output.

You set the $_SESSION[] wherever you have the data.

You can get the data after login using the same $_SESSION[] array. It will be populated as soon as session_start() has been called.

Check http://www.w3schools.com/php/php_sessions.asp and http://php.net/manual/en/ref.session.php . Hope this will help you.

Edit:

Your code should something like :

session_start();
$_SESSION['temp'] = array('GT_title' => $SEStitle, 'GT_actual_duration' => $SESactualduration, 'SEScalstartdate' => $calstartdate, 'GT_picture' => $picture, 'GT_total_duration' => $SEStotalduration, 'GT_total_dives' => $SEStotaldives, 'GT_total_price' => $SEStotalprice, 'GT_total_duration' => $SEStotalduration, 'GT_specifications' => $SESspecifications);


echo $_SESSION['temp']['GT_title'];//the value of $SEStitle will be here...

It might give you an idea what is going on behind the scene. Also REMEMBER that you have to call session_start() function in the top of the page where you want to use $_SESSION[]