logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: Apache 2.2.3 and PHP5 - Module - Sessions help
Author
DuMont



Joined: 16 Nov 2006
Posts: 13

PostPosted: Fri 17 Nov '06 14:31    Post subject: Apache 2.2.3 and PHP5 - Module - Sessions help Reply with quote

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

Code:
Array
(
    [uid] =>
)


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

PostPosted: Fri 17 Nov '06 15:48    Post subject: Reply with quote

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

PostPosted: Fri 17 Nov '06 15:53    Post subject: Reply with 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
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Fri 17 Nov '06 16:04    Post subject: Reply with quote

To set a session var please use $_SESSION['uid'] = 2;
Back to top
DuMont



Joined: 16 Nov 2006
Posts: 13

PostPosted: Fri 17 Nov '06 16:05    Post subject: Reply with quote

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
Code:
uid|N;
Back to top
DuMont



Joined: 16 Nov 2006
Posts: 13

PostPosted: Fri 17 Nov '06 16:07    Post subject: Reply with quote

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

PostPosted: Fri 17 Nov '06 16:52    Post subject: Reply with quote

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


Reply to topic   Topic: Apache 2.2.3 and PHP5 - Module - Sessions help View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner