Author |
|
DuMont
Joined: 16 Nov 2006 Posts: 13
|
Posted: Fri 17 Nov '06 14:31 Post subject: Apache 2.2.3 and PHP5 - Module - Sessions help |
|
|
I finally got php working as a module on apache 2.2.3 but last time I installed php as a module, I had problems with sessions, so this was the first thing I tried out. I have a index.php which sets a session variable and provides a link to index2.php which dumps the current session variables. The problem is that it remembers the name of the variables but not the actual value.
index.php
Code: | <?
session_start();
$uid = 2;
session_register("uid");
echo 'click <a href="index2.php">here</a>';
?> |
index2.php
Code: | <?
session_start();
if(!session_is_registered("uid")){
echo 'no session registered!';
} else {
echo '<pre>';
print_r($_SESSION);
echo '</pre>';
}
?> |
The problem is all that is dumped to the screen on index2.php is
Please can someone tell me how to get sessions working correctly. Thanks for anyhelp given |
|
Back to top |
|
Brian
Joined: 21 Oct 2005 Posts: 209 Location: Puyallup, WA USA
|
Posted: Fri 17 Nov '06 15:48 Post subject: |
|
|
In your PHP.INI, where do you have the session data being saved to?
Example:
Code: | session.save_path =x:/apache2/php/session_data |
Does the path actually exist, and does your webserver have permission to write to this directory? |
|
Back to top |
|
DuMont
Joined: 16 Nov 2006 Posts: 13
|
Posted: Fri 17 Nov '06 15:53 Post subject: |
|
|
Yes it does. Plus if it didn't it woudn't even remember the variable names. But it does remember the variable names, just not the *cough*swears*cough* values |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7360 Location: Germany, Next to Hamburg
|
Posted: Fri 17 Nov '06 16:04 Post subject: |
|
|
To set a session var please use $_SESSION['uid'] = 2; |
|
Back to top |
|
DuMont
Joined: 16 Nov 2006 Posts: 13
|
Posted: Fri 17 Nov '06 16:05 Post subject: |
|
|
It is not saving the information as I can manually go and open any of the session files and it hasn't stored the number 2 but it has stored the variabe name.
read out from session file
|
|
Back to top |
|
DuMont
Joined: 16 Nov 2006 Posts: 13
|
Posted: Fri 17 Nov '06 16:07 Post subject: |
|
|
Thanks James Blond. It is working fine now.
Thank you so much.
How come when you register a variable with a session, it doesn't store its current value anymore? |
|
Back to top |
|
Brian
Joined: 21 Oct 2005 Posts: 209 Location: Puyallup, WA USA
|
Posted: Fri 17 Nov '06 16:52 Post subject: |
|
|
Quote: | Yes it does. Plus if it didn't it woudn't even remember the variable names. But it does remember the variable names, just not the *cough*swears*cough* Very Happy values |
Good point. It is early, I did not consider that ... LOL. |
|
Back to top |
|