unix/linux vs. windows and sessions

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
imstupid
Forum Commoner
Posts: 84
Joined: Fri Feb 18, 2005 1:24 pm

unix/linux vs. windows and sessions

Post by imstupid »

hey everybody-
sorry to bring this up again, but I'm still having trouble starting the sessions on a windows server. I know the code is right because I've copied it to a linux host and it works fine. This new client is running on a windows server, and I don't have direct access to the php.ini file, so I keep having to tell the support at the web host to try different things one at a time and I think he's getting frustrated. Here's what I've done:

the session.save_path is correct, with necessary permissions and he says there are temporary files in there

I've also had him create the 'temp' folder and set permissions with no luck
Session Support = enabled
display_errors + error_reporting both on, but

Code: Select all

ini_set('error_reporting', E_ALL); 
ini_set('display_errors', TRUE);
displays nothing.

After searching the forum for a few days the closest I got to an answer was this link:
viewtopic.php?t=23533

And was wondering if the last post was the answer
I noticed that session.auto_start wasn't set..
that is the only thing on phpinfo() that is off under the sessions section.

Any help you can give me would be great, or advice on what to tell him to is also appreciated. I hope everyone is doing well, and sorry to bring up yet another sessions question.

J
wyred
Forum Commoner
Posts: 86
Joined: Mon Dec 20, 2004 1:59 am
Location: Singapore

Post by wyred »

Did you call the session_start() function at start of your PHP page?

session.auto_start does the same thing but for all your pages. You may not want this for pages that do not require session variables at all. Starting sessions for pages that do not require it merely introduces unneccessary overhead.
imstupid
Forum Commoner
Posts: 84
Joined: Fri Feb 18, 2005 1:24 pm

Post by imstupid »

yep, session_start() is called at the top.

loginscript.php:

Code: Select all

connect code here..
query stuff here...

if ($count == 1 ) {
		
		$_SESSION['username'] = "success"; 

		header( "Location: http://www.example.com/page2.php" );
	}
page2.php:

Code: Select all

<?php 
	session_start(); 
	header("Cache-control: private"); 
	
	if ( !isset( $_SESSION['username'] ) ) {
	
	header( "Location: http://www.example.com/login.html" );
		exit;
	}
	
?>

rest of the page here...
thanks for the response.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

In the first page, you already write to $_SESSION without a call to session_start...

On windows, the problem is that the .ini files delivered with php have session.save_path=/tmp.
Change this to c:/windows/tmp or whatever (make sure it exists), restart your webserver and you're set ;)
Post Reply