win32 session problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eoin
Forum Newbie
Posts: 6
Joined: Mon May 12, 2003 3:39 am

win32 session problem

Post 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

?>
ame12
Forum Newbie
Posts: 5
Joined: Thu Jul 04, 2002 8:22 am

track cookies

Post 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
===================================================
eoin
Forum Newbie
Posts: 6
Joined: Mon May 12, 2003 3:39 am

Post 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.
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post 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???
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post 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 :(
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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?
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post 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 :(
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

so you changed the right php.ini?

Code: Select all

<?php phpinfo(); ?>
will tell you.
Last edited by volka on Mon May 12, 2003 4:49 pm, edited 1 time in total.
eoin
Forum Newbie
Posts: 6
Joined: Mon May 12, 2003 3:39 am

Post by eoin »

No log or buffered errors here.

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

Eoin.
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post 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)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply