Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sessions not working - any ideas?

Status
Not open for further replies.

Microbe

Programmer
Oct 16, 2000
607
AU
Hey folks,

I recently trashed my computer and after rebuilding with XP Pro running IIS, mySQL, PHP 5.2.2 sessions seem to have broken.

Here's an example of my test pages:
test1.php
Code:
session_start();

$_SESSION["test"] = "testing";

header("Location:test2.php");
test2.php is simply
Code:
session_start();
echo "session = " . $_SESSION["test"];
but I don't get the session variable displayed.

When I upload it to my server it works fine, but not on my development box...very frustrating and I just can't see the problem.

I hate loooong bits of code, but at the tisk of putting people off, here is the session section from phpinfo
Code:
session
Session Support 	enabled
Registered save handlers 	files user
Registered serializer handlers 	php php_binary wddx

Directive	Local Value	Master Value
session.auto_start	Off	Off
session.bug_compat_42	Off	Off
session.bug_compat_warn	On	On
session.cache_expire	180	180
session.cache_limiter	nocache	nocache
session.cookie_domain	no value	no value
session.cookie_httponly	Off	Off
session.cookie_lifetime	0	0
session.cookie_path	/	/
session.cookie_secure	Off	Off
session.entropy_file	no value	no value
session.entropy_length	0	0
session.gc_divisor	1000	1000
session.gc_maxlifetime	1440	1440
session.gc_probability	1	1
session.hash_bits_per_character	5	5
session.hash_function	0	0
session.name	PHPSESSID	PHPSESSID
session.referer_check	no value	no value
session.save_handler	files	files
session.save_path	C:\DOCUME~1\Steve\LOCALS~1\Temp\php\session	C:\DOCUME~1\Steve\LOCALS~1\Temp\php\session
session.serialize_handler	php	php
session.use_cookies	On	On
session.use_only_cookies	Off	Off
session.use_trans_sid	0	0
The one thing I notice is that the session file doesn't exist in the temp directory. Permissions seem OK.

Wasting time on this sort of thing is crap when it should be working...sigh...

Thanks in advance.

Steve Davis

NOTE: This sig does not include any reference to voting, stars, or marking posts as helpful as doing so is cause for membership termination.
 
probably a race condition issue.

try adding this
Code:
session_write_close();
before your redirection in the first script
 
Does the user as which IIS runs have permission to write to the directory where PHP is going to store session information? (In your case, C:\DOCUME~1\Steve\LOCALS~1\Temp\php\session)

What version of IIS are you running? Microsoft has a unique interpretation of the HTTP spec, namely with some versions of IIS (actually, I think all pre-IIS v6) not sending cookies if your code sets a "Location:" header. See
If you change the first script to read:

Code:
session_start();

$_SESSION["test"] = "testing";

print '<a hreaf="test2.php">click here</a>';

does it work when you click on the displayed link?





Want the best answers? Ask the best questions! TANSTAAFL!
 
Thanks for both suggestions, but neither of them worked.

grrr... and sigh...






Steve Davis

NOTE: This sig does not include any reference to voting, stars, or marking posts as helpful as doing so is cause for membership termination.
 
Aha...solved it.

The problem was in fact permissions but rather than the user needing permissions on the session directory iuser_machine needed permission.

Thanks for the suggestions.

Steve Davis

NOTE: This sig does not include any reference to voting, stars, or marking posts as helpful as doing so is cause for membership termination.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top