tags:

views:

35

answers:

2

when I run this code for the first time

<?php
session_start();
echo SID;
?>

, I get some thing like:

PHPSESSID=9o2bhrqmln2j52caspdhholhk7

but when I refresh I get a blank page

Until I remove the PHPSESSION cookie and start a new one ... is that normal or I have a problem ?

+6  A: 

The manual says:

Alternatively, you can use the constant SID which is defined if the session started. If the client did not send an appropriate session cookie, it has the form session_name=session_id. Otherwise, it expands to an empty string. Thus, you can embed it unconditionally into URLs.

It's not meant to contain the session id, it's meant to be attached to URLs if cookies are disabled.

deceze
aha , so if the cookie works , it becomes empty ?
Naughty.Coder
@Naughty Precisely. :)
deceze
@Naughty To get the session id, use `session_id()`;
deceze
+1  A: 

Yes, it is normal. this constant being populated only when no cookie present. Why do you think you have any problem? What's the use of this constant anyway?

Col. Shrapnel