Session problem with XP, Apache 2.0.49 and PHP 4.3.4

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
deljim
Forum Newbie
Posts: 9
Joined: Thu Apr 22, 2004 3:59 am
Location: Belgium

Session problem with XP, Apache 2.0.49 and PHP 4.3.4

Post by deljim »

Hi all,
I'm running apache 2 and PHP 4.3.4 under WinXP;
My problem is that php opens a new session when i'm going from a page to another.
So the very simple code below doesn't work, the session variables cannot be retreived because the session change... The same code works on a Linux OS.
Do someone knows that problem? please help!
Thx. Jim


file : test1.php :

Code: Select all

<?php

session_start();
$_SESSION['test'] = "the_test";

?>

file : test2.php

Code: Select all

<?php

session_start();
print($_SESSION['test']);

?>
stoyan
Forum Newbie
Posts: 3
Joined: Thu Apr 22, 2004 2:13 am
Contact:

Post by stoyan »

Turn error reporting on and check if the session directory exists.
deljim
Forum Newbie
Posts: 9
Joined: Thu Apr 22, 2004 3:59 am
Location: Belgium

Post by deljim »

The directory exist and contains the files sess_*
The problem is that it creates a "session file" for each page visited. So when click on a link a new sess file is created. That why I cannot find variable back... Am I clear?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What does the sessions section of your php.ini look like?

Mac
deljim
Forum Newbie
Posts: 9
Joined: Thu Apr 22, 2004 3:59 am
Location: Belgium

Post by deljim »

Here is my php.ini file. I deleted the most of comments to be shorter for reading.

[Session]
; Handler used to store/retrieve data.
session.save_handler = files

session.save_path =E:/Program Files/Peaktime/xmlratserver/Apache/Server/Apache/www/sess_data

; Whether to use cookies.
session.use_cookies = 1

; This option enables administrators to make their users invulnerable to
; attacks which involve passing session ids in URLs; defaults to 0.
; session.use_only_cookies = 1

; Name of the session (used as cookie name).
session.name = PHPSESSID

; Initialize session on request startup.
session.auto_start = 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0

; The path for which the cookie is valid.
session.cookie_path = E:/Program Files/Peaktime/xmlratserver/Apache Server/Apache/www/cookies

; The domain for which the cookie is valid.
session.cookie_domain =

; Handler used to serialize data. php is the standard serializer of PHP.
session.serialize_handler = php

session.gc_probability = 1
session.gc_divisor = 100

session.gc_maxlifetime = 1440

session.bug_compat_42 = 0
session.bug_compat_warn = 0

; Check HTTP Referer to invalidate externally stored URLs containing ids.
; HTTP_REFERER has to contain this substring for the session to be
; considered as valid.
session.referer_check =

; How many bytes to read from the file.
session.entropy_length = 0

; Specified here to create the session id.
session.entropy_file =

;session.entropy_length = 16

;session.entropy_file = /dev/urandom


session.cache_limiter = nocache

; Document expires after n minutes.
session.cache_expire = 180

session.use_trans_sid = 0

url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Tried:

Code: Select all

session.save_path = "E:\Program Files\Peaktime\xmlratserver\Apache\Server\Apache\www\sess_data"
?
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Paths with spaces are require to be enclosed in quotes so as suggested enclose the value of seesion.save_path in quotes.

This is also the case for session.cookie_path, however you should note that the value of session.cookie_path is not a path to save files to. This value represents allowable directories for which the cookie will be accessable. So with your current config only scripts which are in the directory "E:/Program Files/Peaktime/xmlratserver/Apache Server/Apache/www/cookies" and any subsequent sub directories will be able to access the session cookie.
deljim
Forum Newbie
Posts: 9
Joined: Thu Apr 22, 2004 3:59 am
Location: Belgium

Post by deljim »

Thanks for advices!

My code still doesn't work, I "double-quoted" the path, I even tried to put session files in "E:\temp" but no result either. The session file are still created at each page visited...
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Have you tried....

Code: Select all

session.save_path   = "E:\temp";
session.cookie_path = /
Assuming E:\temp is a directory

I had some problems with Apache2 running as a service on win2k, I created an apache user with appropriate permissions and set that user as the logon for the Apache service. Don't think it would make any difference in your case but may be worth a shot.
Post Reply