Sessions trouble

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
shiga
Forum Newbie
Posts: 2
Joined: Thu Nov 05, 2009 4:03 pm

Sessions trouble

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Sessions trouble

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Sessions trouble

Post by pickle »

The directory you've specified doesn't exist.

Do you need to specify the save session path?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
shiga
Forum Newbie
Posts: 2
Joined: Thu Nov 05, 2009 4:03 pm

Re: Sessions trouble

Post 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.
Post Reply