Jump to content

Sessions


paulman888888

Recommended Posts

Just to clarify.

 

Page 1

<?php
session_start();
//then loads of session stuff
?>

 

Page 2

<?php
session_start();
//the session variables has been past on from page 1
?>

 

Page 3

<?php
session_start();
//will the variables from Page 2 still come though to this Page?

?>

 

Thankyou

Paul

Link to comment
Share on other sites

The $_SESSION array will contain everything that you put into it from which ever script. It's cumulative. By default the session goes away when you close the browser.

 

Try these three scripts:

one.php

<?php
session_start();
echo '<pre>' . print_r($_SESSION,true) . '</pre>';
if (isset($_SESSION['one']))
   $_SESSION['one']++;
else
   $_SESSION['one'] = 1;
?>

two.php

<?php
session_start();
echo '<pre>' . print_r($_SESSION,true) . '</pre>';
if (isset($_SESSION['two']))
   $_SESSION['two']++;
else
   $_SESSION['two'] = 1;
?>

three.php

<?php
session_start();
echo '<pre>' . print_r($_SESSION,true) . '</pre>';
if (isset($_SESSION['three']))
   $_SESSION['three']++;
else
   $_SESSION['three'] = 1;
?>

Invoke them in any order in the same browser and see how the $_SESSION array changes.

 

Ken

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.