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
https://forums.phpfreaks.com/topic/115470-sessions/#findComment-593617
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
https://forums.phpfreaks.com/topic/115470-sessions/#findComment-593657
Share on other sites

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.