Page 1 of 1

Help getting Sessionsconfigured on my webserver

Posted: Thu Dec 03, 2009 4:44 pm
by johnpecan
Hello,

I am not new to php, but am new to using sessions. I was trying to get sessions working between files with 2 simple test files, 'test1.php' and 'test2.php'.

test1.php:

Code: Select all

<?php
  session_start();
  $_SESSION['data'] = "you have an active session!";
  echo "<a href=\"test2.php\">go</a>";
  echo " and please pass this: " . $_SESSION['data'];
?>
test2.php:

Code: Select all

<?php
session_start();
    echo $_SESSION['data'];
As you can see, it's a very basic test to prove that the variable 'data' is passed and displayed on test2.php. Unfortunately, this variable does not get passed on my webserver: http://johnhilp.com/test1.php

To confirm that it's some type of configuration issue I tried it on another webserver and it did work with the exact same files. So what kind of configuration issue should I look into? Or what obvious answer did I miss? Thanks in advance.

I apologize in advance if I missed a sticky or other easily searchable post that had my answer. I searched the forums and couldn't find anything.

Re: Help getting Sessionsconfigured on my webserver

Posted: Thu Dec 03, 2009 8:06 pm
by AlanG
Can you post the following code in both files above the session_start() and below the <?php tag, and then post any error messages you get here.

Code: Select all

<?php
 
error_reporting(E_ALL);
ini_set("display_errors", 1);
 
session_start();
It might give you a clearer indication of what's going on.

Re: Help getting Sessionsconfigured on my webserver

Posted: Fri Dec 04, 2009 4:09 am
by johnpecan
Thanks for the tip.

I see all the warnings that are coming from session_start();
I'm calling my web host's customer service and asking them to fix it, I don't think I have access to php.ini on a shared system. Here they are from http://johnhilp.com/test1.php

Warning: session_start() [function.session-start]: open(/var/php_sessions/sess_e2a345e6684d148fbf35d7e17529bf4f, O_RDWR) failed: No such file or directory (2) in /hermes/bosweb/web175/b1754/ipw.johnhilp/public_html/test1.php on line 4

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /hermes/bosweb/web175/b1754/ipw.johnhilp/public_html/test1.php:4) in /hermes/bosweb/web175/b1754/ipw.johnhilp/public_html/test1.php on line 4

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /hermes/bosweb/web175/b1754/ipw.johnhilp/public_html/test1.php:4) in /hermes/bosweb/web175/b1754/ipw.johnhilp/public_html/test1.php on line 4
go and please pass this: you have an active session!
Warning: Unknown(): open(/var/php_sessions/sess_e2a345e6684d148fbf35d7e17529bf4f, 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 (/var/php_sessions) in Unknown on line 0

Re: Help getting Sessionsconfigured on my webserver

Posted: Fri Dec 04, 2009 4:23 am
by johnpecan
Updated the 'session.save_path'. It was incorrect. Warnings all gone and it works. Thanks!