Page 1 of 1
sessions
Posted: Sun Sep 25, 2005 11:46 am
by crzyman
On page one I have this at the top of the page:
Code: Select all
session_start();
header("Cache-control: private");
$bandname = "aaa";
$_SESSION["bandname"] = $bandname;
And on page two I have this:
Code: Select all
session_start();
header("Cache-control: private"); //IE 6 Fix
$bandname = $_SESSION['bandname'];
The problem is the value of $_SESSION['bandname'] isn't being passed. Can someone please tell me what I am doing wrong? Many thanks.
Posted: Sun Sep 25, 2005 12:13 pm
by feyd
are you positive the session actually set? If you have any output before the session is started, the session will not be able to set correctly.
Make sure you have error_reporting turned on to E_ALL, do not disable any types of messages.
Posted: Sun Sep 25, 2005 4:52 pm
by crzyman
Thanks for looking. I am positve that there is no output prior to the session starting. I am not sure how to turn on error_reporting to E_ALL If it is on by default then it must still be on. I also don't know how to disable any types of messages so that to must be good. I don't know why this won't work. Thanks for your time.
Posted: Sun Sep 25, 2005 5:02 pm
by feyd
first, look at the output of phpinfo() to see where your error_reporting setting is at (it should be at 2047 I believe).. at any rate you can check what's actually set by going into your php.ini. By default, I think most versions set E_ALL & ~E_NOTICE
While you are in there, check to see that display_errors is on/1.
Posted: Sun Sep 25, 2005 5:25 pm
by crzyman
error_log /logs/scripts.log /logs/scripts.log
error_reporting no value no value
This is what I see in my php.inf. I get sessions to work if I use this method.
page 1
Code: Select all
<?
session_register("bandname");
$bandname = "aaa";
?>
<FORM METHOD="POST" ACTION="test.php">
<input type="Submit" name=$bandname value="Submit">
</form>
page 2
Code: Select all
<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
echo "<strong>Step 2 - Register Session </strong><br />";
?>
Welcome to my website <strong><? echo $_SESSION['bandname']; ?></strong>!
That works perfect, but I need it to work the way I have it in my original post. Any ideas?
Posted: Sun Sep 25, 2005 5:34 pm
by feyd
session_register() should not be used at all costs, as you may know.
Did you change error_reporting and display_errors to the values I've said (E_ALL and On) respectively in your php.ini? (You should need to restart the web server process as well, depending on installation settings)
it seems strange that session_register() would work though.. hmmm....
Posted: Sun Sep 25, 2005 5:54 pm
by crzyman
I will do what you said. Thank you for your help.