Page 1 of 1

Sessions trouble

Posted: Fri Nov 06, 2009 1:39 pm
by shiga
viewtopic.php?f=1&t=102341&hilit=sessio ... ot+passing

The problem in that thread is quite similiar to what i'm facing, but I still can't figure out the issue i'm having.

I made this small 2-page test to see if I could get sessions to work listed per below:

First page:

Code: Select all

<?php
//show all php errors associated with this page
error_reporting(E_ALL);
ini_set('display_errors', '1');
 
session_save_path("/home/users/web/b560/as.innovati/public_html/cgi-bin/tmp"); 
session_start();
 
$_SESSION['color'] = "red";
$_SESSION['name'] = "Brosef";
$_SESSION['ID'] = "4";
 
if (isset($_POST['submit']))
    {
        header('Location: http://www.' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/test2.php');
    }
?>
 
<html>
<head>
<title>test variable sessions pass</title>
</head>
<body>
<form name="form1" action="./test.php" method="post">
<input type="submit" name="submit" value="next page" >
</form>
</body>
</html>
Second Page:

Code: Select all

<?php
session_save_path("/home/users/web/b560/as.innovati/public_html/cgi-bin/tmp"); 
session_start();
 
//show all php errors associated with this page
error_reporting(E_ALL);
ini_set('display_errors', '1');
 
echo $_SESSION['color'];
echo $_SESSION['name'];
echo $_SESSION['ID'];
 
print_r($_SESSION);
 
?>
Output Error on the first page:

Code: Select all

Warning: session_start() [function.session-start]: open(/home/users/web/b560/as.innovati/public_html/cgi-bin/tmp/sess_8ff8c1807f3d1fc5735cb139d1bfcfdb, O_RDWR) failed: No such file or directory (2) in /hermes/web03/b560/as.innovati/public_html/login/test.php on line 7
 
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /hermes/web03/b560/as.innovati/public_html/login/test.php:7) in /hermes/web03/b560/as.innovati/public_html/login/test.php on line 7
 
Warning: Unknown(): open(/home/users/web/b560/as.innovati/public_html/cgi-bin/tmp/sess_8ff8c1807f3d1fc5735cb139d1bfcfdb, O_RDWR) failed: No such file or directory (2) in Unknown on line 0
 
Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/home/users/web/b560/as.innovati/public_html/cgi-bin/tmp) in Unknown on line 0
The provider has me specifically save the sessions in a specified path which is found above session_start but other than that not sure why it doesn't want to save.

Re: Sessions trouble

Posted: Fri Nov 06, 2009 2:02 pm
by RobertGonzalez
What are the permissions on that directory? You might not be able to write to that directory which might be causing your issues.

Re: Sessions trouble

Posted: Fri Nov 06, 2009 2:03 pm
by pickle
The directory you've specified doesn't exist.

Do you need to specify the save session path?

Re: Sessions trouble

Posted: Fri Nov 06, 2009 3:16 pm
by shiga
I'm sorry guys, it was a simple directory issue as stated on the first set of errors. :oops:

I got confused somehow thinking that the root began from "public_html" instead of just "/" if that makes any sense.
pickle wrote:The directory you've specified doesn't exist.

Do you need to specify the save session path?
The host indeed wants me to save the sessions in a specific directory. I figured thats what they wanted since my session variables wouldn't save anyway.

Thanks to you all for the time spent on my issue.