Re: please help with sessions problem
| From: | Richard Lynch | Date: | Tue, 28 Nov 2000 23:24:35 +0000 |
| Subject: | Re: please help with sessions problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27723@lists.php.net to get a copy of this message | ||
Sessions time out as specified in your php.ini
----- Original Message -----
From: Ed Lazor <osmosis@atfantasy.com>
Newsgroups: php.general
Sent: Sunday, November 26, 2000 2:55 PM
Subject: [PHP] please help with sessions problem
> Hi Everyone =) I posted on Friday and haven't seen any response, so I
> figured I'd try again.
>
> I setup PHP4 to store session variables using the handler from here:
> http://gateway.digitaria.com/~chris/php/mysql_session_handler/
>
> I can start sessions, register, retrieve, and unregister variables. I was
> able to quickly setup a system where people can log into the site, etc. I
> also setup a neat little extra. By adding two additional fields to the
> sessions database (username, url), and adding these fields to the function
> that writes the sessions (listed below), I'm able to tell who's logged in
> and which page they are on. Pretty cool =) I've run into one problem tho
> :( If you don't do anything on your browser for a while and go back,
> things are broken; Session variables and the ability to store them is
> lost. Did I screw something up? Any idea of what the solution would be?
>
> Thanks in advance for any help you could provide! =)
>
> -Ed
>
> ---------- modified sess_write --------------------
>
> function sess_write($key, $val) {
> // Added handling for Username and REQUEST_URI to make user
> administration easier. Ed, 11-22-2000
> global $SESS_DBH, $SESS_LIFE, $user, $REQUEST_URI;
>
> // Added for tracking users through the site - Ed, 11-22-2000
> if (empty($user["Username"]))
> $Username = "nobody";
> else
> $Username = $user["Username"];
>
> $expiry = time() + $SESS_LIFE;
> $value = addslashes($val);
>
> // SQL statement modified to add $Username and $REQUEST_URI. Ed,
> 11-22-2000
> $qry = "INSERT INTO sessions VALUES ('$key', $expiry,
> '$value',
> '$Username', '$REQUEST_URI')";
> $qid = mysql_query($qry, $SESS_DBH);
>
> // SQL statement modified to add $Username and $REQUEST_URI. Ed,
> 11-22-2000
> if (! $qid) {
> $qry = "UPDATE sessions SET expiry = $expiry, value =
> '$value', username = '$Username', url = '$REQUEST_URI' WHERE
> sesskey =
> '$key' AND expiry > " . time();
> $qid = mysql_query($qry, $SESS_DBH);
> }
>
> return $qid;
> }
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>