470,815 Members | 1,320 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

Session example problem

I tried the following session example

/**************The first page - page1.php *******************/
// page1.php


echo 'Welcome to page #1';

$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();

// Works if session cookie was accepted
echo '<br /><a href="page2.php">page 2</a>';

// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
/************************************************** **********/

/************The second page - page2.php***************************/
// page2.php


echo 'Welcome to page #2<br />';

echo $_SESSION['favcolor']; // green
echo $_SESSION['animal']; // cat
echo date('Y m d H:i:s', $_SESSION['time']);

// You may want to use SID here, like we did in page1.php
echo '<br /><a href="page1.php">page 1</a>';
/************************************************** ***********/

When I copy-paste the previous code and run it, the echo commands in
page2.php didn't print the variable values on the screen. I don't know
if I'm doing something wrong,can anyone help me?
What is the purpose of the SID when you pass it along, as in the

thanks in advance
Jul 17 '05 #1
0 1304

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Paul Yanzick | last post: by
1 post views Thread by Werner | last post: by
5 posts views Thread by ASP.Confused | last post: by
5 posts views Thread by Åženol Akbulak | last post: by
6 posts views Thread by Bhagya | last post: by
9 posts views Thread by Josh | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.