Page 1 of 1

Sessions - Am I missing something

Posted: Sun May 23, 2004 1:27 pm
by mendingo
As I understand it, once a session variable is set, it is set as long as the browser is left open, right?

So with this code:

Code: Select all

session_start;
print($_SESSION&#1111;'test']."<br>");
if(!isset($_SESSION&#1111;'test']))
&#123;
	$_SESSION&#1111;'test'] = "hello";
&#125;	
print($_SESSION&#1111;'test']."<br>");
When the page is first loaded, it displays en empty line, then "hello", as it should.

However, when I referesh the page, surely it should print "hello" twice? Why doesn't it? Is this a php bug? Am I missing something?

Posted: Sun May 23, 2004 1:32 pm
by Weirdan
session_start is a function, therefor it should be called as:

Code: Select all

session_start();
//........ rest of the code
Note the parethesis.

Posted: Sun May 23, 2004 1:45 pm
by mendingo
Sorry, yeah, the perentheses are there in the real code... just missed them out when typing it here.

Posted: Sun May 23, 2004 1:52 pm
by d3ad1ysp0rk
It works as expected on my server..

http://lps.no-ip.org/try.php

Try copying the exact code you pasted here, and adding the parenthesis..

Posted: Sun May 23, 2004 2:07 pm
by mendingo
just did, and I still get the same problem.

http://fourleggedostrich.no-ip.com/external/test.php

Perhaps it's a bug in PHP 4.3.0 (which I have installed)... after I've moved around the site where this initially occured a while, it starts working again.

What PHP version do you have?

Posted: Sun May 23, 2004 2:14 pm
by tim
HMMM

I see only one 'hello' for both links given?

Posted: Sun May 23, 2004 3:17 pm
by mendingo
You will... you then need to refresh the page. That's when 2 should appear, because "hello" is already stored in the session