and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi guys,
I am not sure if this is the right place to post this but.........
I have an installation of php running with my Apache server but it does not seem to pass session variables correctly.
I have tested my scripts on another server fine with the session variables being passed and accessed as expected.
However on my server they do not, work I try to access them they appear to be empty.
I have tried turning register_globals in php.ini both on and off but it does not solve the problem.
This is the code I am using to test:
First Script:
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
It doesn't run here, but it's probably your php INI settings. However, that doesn't solve the session problem anyway. What are your httpd.conf settings for sessions?
Check your php session settings by running a phpinfo() page and by looking at your php.ini. Also, try to echo out a session var immediately after setting it to see if it is getting set properly. Lastly, set your error reporting to E_ALL so if there are syntax errors or other errors that are being muted right now, you can see them. That may give you some more information as well.
I tried echoing the session variable after it has been set and before submitting the page and it output the correct value. So it seems it is losing the or not passing the variable once I click the link to the subsequent page/link.
session
Session Support enabled
Registered save handlers files user
Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 Off Off
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /tmp /tmp
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid Off Off
http.conf:
I checked my http.conf file and searched for the word "session" but it returned no results!
OK, before you do anything else clear your broswer cache. Then check your scripts to make sure that session_start() is being called at the very beginning or close to the beginning of the script. Also, make sure no browser output has been sent by the script before session_start() is called. Then run your two scripts...
<?php
session_start();
$_SESSION['test']="ROB";
echo $_SESSION['test'] . ' is the value set for "test".<br />';
echo 'Our current session id is ' . $_SESSION['PHPSESSID'] . '<br />';
echo '<a href="test2.php">Try the test</a>';
?>
<?php
session_start();
echo $_SESSION['test'] . ' is the value set for "test".<br />';
echo 'Our current session id is ' . $_SESSION['PHPSESSID'] . '<br />';
?>
feyd wrote:session_id(), not $_SESSION['PHPSESSID']
Sorry, got a little confused. I think you can reference the Session ID with the constant SID after starting the session. PHPSESSID is the name of the var added to forms the first time a session is called. It is available (on the first form load only) as a $_POST var with the index of PHPSESSID.