Page 1 of 1

win32 session problem

Posted: Mon May 12, 2003 3:39 am
by eoin
Hello,
I'm trying to get a grip on php sessions. I have searched and have seen similar problems on this forum, but none with a suitable solution so here goes:

The following code was taken from the php docs and runs as expected on my *nix box (Apache 1.3.24 + php v4.1.2). Whenever I refresh the page, count is incremented.

Code: Select all

<?php
session_start();

if(!isset($_SESSION['count']))
{
    echo "Setting count<br>";
    $_SESSION['count'] = 0;
} else
{
    echo "Incrementing count<br>";
    $_SESSION['count']++;
}

echo "Count: " . $_SESSION['count'];
?>
When I try running the script on my local windows machine (Apache 2.0.45 + php v4.3.1) count is not incremented. On further inspection I found that a new session file with a new sid is being created in my winnt-temp directory on every refresh. My browser flags a cookie when running the script on *nix but not on windows, so I presume this is the problem. My php.ini setup on windows seems to be the same as the *nix setup, but I can't think of anything else that could cause this problem.

Settings of relevance:
session support is enabled
register globals is off
session.cookie_path = /
session.save_handler = files
session.use_cookies = On
session.use_trans_sid = Off
session.save_path = e:\winnt\temp

Thanks in advance,
Eoin.

Code: Select all

<?php

?>

track cookies

Posted: Mon May 12, 2003 11:46 am
by ame12
you need to determine whether a session cookie is actually being delivered... check IE (or whatever browser you're using) to have it prompt you to accept cookies. that way you can see whether you're getting a session cookie. that's the only thing i can think of...



===================================================
BadBlue: tiny personal web server for PHP & Windows
Free download - http://badblue.com/down.htm
===================================================

Posted: Mon May 12, 2003 12:46 pm
by eoin
Apologies if I didn't make my original post clear:
...my browser flags a cookie when running the script on *nix but not on windows, so I presume this is the problem...
So, no I'm not getting a session cookie. Any ideas on why this may be? As I said, I get a session cookie when running the script on *nix from the same browser, so my browser settings are ok.

Thanks for the input,
Eoin.

Posted: Mon May 12, 2003 12:59 pm
by Coco
im having a similar problem.... tho i think its possible a bad config?

the error i get is:
Warning: session_start() [function.session-start]: open(/tmp\sess_1ddc18d54d94c1818415e999ab8e9fde, O_RDWR) failed: No such file or directory (2) in c:\program files\apache group\apache\htdocs\stuff\lite\include\config.php on line 8

but when it comes to webservers etc im 100% newbie :(
anyone any ideas?

setup is apache 1.3.27, php 4.2.2 with mysql 3.23 on winxp


I managed to find the part in the php.ini:

Code: Select all

; Argument passed to save_handler.  In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this 
; variable in order to use PHP's session functions.
session.save_path = /tmp
But change it to what???

Posted: Mon May 12, 2003 1:18 pm
by Coco
i tried changing it to 'c:/php/tmp' but all thats done is add a load of latency to the system and not fixed the error :(

Posted: Mon May 12, 2003 1:43 pm
by volka
needs to be a valid directory the script has read/write access to
Eoin's session.save_path = e:\winnt\temp probably is valid but nevertheless have you checked the server's (error/access-)log?

Posted: Mon May 12, 2003 2:00 pm
by Coco
thing is...... no matter what i put in php.ini the error message is the same, its saying the same directory thats missing :(

Posted: Mon May 12, 2003 2:18 pm
by volka
so you changed the right php.ini?

Code: Select all

<?php phpinfo(); ?>
will tell you.

Posted: Mon May 12, 2003 4:34 pm
by eoin
No log or buffered errors here.

Coco, this could really have been handled in a separate thread.

Eoin.

Posted: Mon May 12, 2003 4:41 pm
by Coco
sorry :(
ive edited most the guff out

(and if you look at my first post... you will find that my problem was kinda similar to yours)

Posted: Tue May 13, 2003 2:37 am
by twigletmac
Coco wrote:(and if you look at my first post... you will find that my problem was kinda similar to yours)
But thread hijacking is unfair - you can reference similar threads in your own... :wink:

Mac