Do you have a question? Post it now! No Registration Necessary. Now with pictures!
May 5, 2008, 6:52 am
rate this thread
My impression of sessions is once the $_SESSION['variable'] is set, the
$_SESSION['variable'] is available on all pages as long as the
session_start() is on the top of each page.
I have used sessions a years ago successful, but I am having a problem that
I cannot figure out. I appreciate the help.
<form name="form1" method="post" action= "page2.php">
form1 with <input name="variable"> variable = 'name'
Page1 calls page2.php by submit form1
page1 echoes .....1234 the session_id() number
$_SESSION['myname'] = $_POST['variable'];
<form name="form2" method="post" action= "page3.php">
form2 calls page3.php with submit
Page2 calls page3.php by submit form2, the $_SESSION['myname'] is not in
page2 echoes .... 1234 the session_id() number
page2 echoes name therefore $_SESSION['myname'] = name which is correct
page3 echoes .... 1234 session_id() is correct for all pages
page3 echoes nothing therefore $_SESSION['myname'] = is empty the value was
not carried through to page 3
1. What can cause the session variable to loose the value even though the
session_id() is carried through?
2. I want to use $_SESSION['myname'] on a page out of sequence, that is,
skipping one page. Can this be done? Isn't session variables suppose to be
available to all pages? not only sequential apges.
Thanks for the help. I know I am missing something, but what?
Could be several things. The most common is something ahead of your
session_start() call - anything, even whitespace, will cause the headers
to be sent and session_start() to fail.
Another common problem is that your webserver userid does not have write
access to the temporary directory, or the temporary directory is set
incorrectly. There are others.
In your php.ini file, ensure you have:
This should show you the error in your code.
There is no "sequence" of pages. Each page is an individual
transaction. Anything set in the session is available until unset or
the session is terminated.
Remove the "x" from my email address
JDS Computer Training Corp.