Page 1 of 1

unix/linux vs. windows and sessions

Posted: Tue Sep 13, 2005 7:37 pm
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

Posted: Tue Sep 13, 2005 11:46 pm
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.

Posted: Wed Sep 14, 2005 6:59 am
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.

Posted: Wed Sep 14, 2005 7:31 am
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 ;)