Page 1 of 1

php sessions

Posted: Fri Nov 21, 2008 7:28 pm
by vickriz
Hello I'm having a little problem with php sessions. I'm trying to test the code below and wants to print the value after submit the form. http://abetterc.ipower.com/sessionTest1.php
This is my codes:
sessionTest1.php

Code: Select all

<?php
  session_save_path(home/users/web/b1631/ipw.abetterc/public_html/cgi-bin/tmp);
  session_start();
?>
<html>
<head><title>Testing Sessions page 1</title></head>
<body>
<?php
  $_SESSION['session_var'] = "testing";
  echo "This is a test of the sessions feature.
       <form action='sessionTest2.php' method='POST'>
         <input type='hidden' 
                name='form_var' value='testing'>
         <input type='submit' value='go to next page'>
       </form>";
?>
</body></html>
sessionTest2.php

Code: Select all

<?php
  session_save_path(home/users/web/b1631/ipw.abetterc/public_html/cgi-bin/tmp);
  session_start();
?>
<html>
<head><title>Testing Sessions page 2</title></head>
<body>
<?php
  echo "session_var = {$_SESSION['session_var']}<br>\n";
  echo "form_var = {$_POST['form_var']}<br>\n";
?>
</body></html>
The problem is that the session_var is not appearing. How to correct my code? Any advice will appreciated very much.

Thanks,

Vick

Re: php sessions

Posted: Fri Nov 21, 2008 8:23 pm
by VladSun

Code: Select all

session_save_path(home/users/web/b1631/ipw.abetterc/public_html/cgi-bin/tmp);
=>

Code: Select all

session_save_path('/home/users/web/b1631/ipw.abetterc/public_html/cgi-bin/tmp');
and make sure this directory is writable ...

Re: php sessions

Posted: Fri Nov 21, 2008 11:00 pm
by califdon
Perhaps you have a need to specify the save path for the session variables, but letting it use the default is satisfactory for most situations.