$_SESSION variable not carrying

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am trying to do some simple session stuff. However it does not seem
as though the session variable is being created for my site. I am
running the latest version of PHP and apache that I installed as part
of WAMP. Machine is XP SP2.

Basically I am trying to do something simple such as:


// initialize a session

// increment a session counter

// print value
echo "You have viewed this page " . $_SESSION['counter'] . " times";


However my counter does not increment. I can also not see where any
sort of cookie has been created within IE, although firefox shows the

Content: 4s0n98f1s7jea6kg11psi4ckd3
Path: /
Send for: Any type of connection
Expires: at end of session

I am not sure about the Path: variable though. The address for my site

physical is C:\wamp\www\recipe

Here are some of the contents of my php.ini file:

session.save_handler = files

session.save_path = "C:\Windows\temp "

session.use_cookies = 1

session.name = PHPSESSID

session.auto_start = 0

session.cookie_lifetime = 0

session.cookie_path = /

session.cookie_domain =

Any suggestions would be greatly appreciated!

Re: $_SESSION variable not carrying

Quoted text here. Click to load it

you don't see your new session/cookie value until you call it from the  

Also, this might make more sense:
$_SESSION['counter'] = $_SESSION['counter']++;

Re: $_SESSION variable not carrying

Good Man wrote:
Quoted text here. Click to load it

  First of all, never use uninitialized variables. Even if you think  
this is o.k. if(!isset($_SESSION['counter'])) $_SESSION['counter']=0; is  
not hard code but now you don't depend of session vars behavior modified  
with every PHP version.

Quoted text here. Click to load it
  Will never increment it because of post-increment.

  I think you mean this:
  $_SESSION['counter'] = $_SESSION['counter']+1;

Re: $_SESSION variable not carrying

Alexey Kulentsov wrote:
Quoted text here. Click to load it

Or, just


$_SESSION['counter'] = $_SESSION['counter']++;

is an "undefined operation" - it could contain the old value or the new  
value.  Either result could be considered "legal".

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: $_SESSION variable not carrying

dpinion@gmail.com wrote:

Quoted text here. Click to load it

Is that space character inside the path really there? If so, remove it.

Also, try using "/" instead of "\" in the path -- backslashes are used in
PHP strings to escape special characters. In particular, your path
contains "\t" which PHP may treat as a tab character!

Lastly, if you're using NTFS (you don't specify) check which user Apache is
running as, and make sure that the Temp folder is writable by that user.
To be sure, you could try giving "Full Control" on the Temp folder to
"Everyone". (I think that's the terminology used in XP.)

Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 29 days, 15:47.]

               Parsing an HTML Table with PEAR's XML_HTTPSax3

Site Timeline