Session


Posted on 16th Feb 2014 07:03 pm by admin

I am having a little trouble with a session. Not sure if it is my browser or what. I know I do not have any trouble logging into forums such at these, so not sure why this is not working.

first the code. Just basic code from php documentation plus some added checks.

Code: <?php
// page1.php

if (session_start()) {
echo "OK";
} else {
echo "FAIL";
}
// echo phpinfo();
// echo getcwd();
echo 'Welcome to page #1';

$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();
print_r($_SESSION);
// 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>';
?>
And

Code: <?php
// page2.php

session_start();

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

echo $_SESSION['favcolor']; // green
echo $_SESSION['animal']; // cat
echo date('Y m d H:i:s', $_SESSION['time']);
print_r($_SESSION);
// You may want to use SID here, like we did in page1.php
echo '<br /><a href="page1.php">page 1</a>';
?>
There is no reason why this should not work. Can someone go to:

http://www.e-sullivan.com/DIITop25/page1.php

and tell me if it works for you? It shows me that the sessions are being started but the variables are not passing between page1.php and page2.php for me.

No comments posted yet

Your Answer:

Login to answer
331 Like 8 Dislike
Previous forums Next forums
Other forums

some query on multilingual website
Hi all,

Which is the simplest and easiest method to make a website multilingual,
is it put

While Problem
i am having a problem with a while statement here is the code
Code: [Select]<?php
sess

ctype() validation - allowing illegal characters
Hello,
I use ctype() to filter and validate a user form. However, I am trying to allow certain c

mysqli_fetch_assoc returns multiple arrays, how to return a single array
Hello, I am using mysqli_fetch_assoc which is returning multiple rows, so it looks like:

Code

Simultaneous select/update/insert
Hi

How would I need to go about when 2 users update a single row simultaneous? And how would

Question about GD library
I am trying to make an image that shows a random quote from my database.


However I want t

Sum of Values in an Array
This is probably really simple... but it's been years since I've written anything, so bare with me!<

Array becomes unset by itself?
Hi,

I have a bit of experience with PHP but not extensive. It seems I cannot store any items

PHP Include w/If IE Condition Statement?
I was having a problem with Internet Exploder (big surprise, right?) displaying my drop down menus i

rdns with php
I am trying to build a script that will show all of the different domains that are hosted on the sam

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash