By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,965 Members | 1,702 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,965 IT Pros & Developers. It's quick & easy.

HOW TO: make a session valid only as long as user on site?

P: n/a
gsb
I trying to use sessions to save a user name/id after login.
If the user leaves the site and comes back, how do I force a new session and
login?
Jul 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"gsb" <gs*@QWest.net> schrieb:
I trying to use sessions to save a user name/id after login.
If the user leaves the site and comes back, how do I force a new session and
login?


No chance.

Regards,
Matthias
Jul 16 '05 #2

P: n/a
> If the user leaves the site and comes back, how do I force a new session
and login?

use cookies for this.

Jul 16 '05 #3

P: n/a
"Bernhard Hörlberger" <sh********@netway.at> schrieb:
If the user leaves the site and comes back, how do I force a new session
and login?


use cookies for this.


And how do you know when to resume an existing session and when to
create a new session?

Regards,
Matthias
Jul 16 '05 #4

P: n/a
Terry Austin <ta*****@hyperbooks.com> schrieb:
Cookies have a time to live setting, referred to as the expire time. If
unset, the cookie automatically expires when the browser is closed.


That's OK, but the question was about "leaving the site". It seems like
problem of the definition of "leaving". Does "leave" mean, that you
closed the browser? Does it mean, that you did not show any activity in
the last 5 minutes?

So, if the nameless poster calling himself "gsb" tells us what he means
with "leaving", we might give him something which you could call a
solution.

Regards,
Matthias
Jul 16 '05 #5

P: n/a
Matthias Esken <mu************@usenetverwaltung.org> wrote in
news:bi**********@usenet.esken.de:
Terry Austin <ta*****@hyperbooks.com> schrieb:
Cookies have a time to live setting, referred to as the expire time. If
unset, the cookie automatically expires when the browser is closed.
That's OK, but the question was about "leaving the site". It seems like
problem of the definition of "leaving". Does "leave" mean, that you
closed the browser? Does it mean, that you did not show any activity in
the last 5 minutes?


I suspect it would *have* to mean one of those two.
So, if the nameless poster calling himself "gsb" tells us what he means
with "leaving", we might give him something which you could call a
solution.

Cookies could be used for either. If you don't set the expire time, the
session lasts until you close the browser. If you want to set a specific
time, set the expire time for the cookie to (for instance) five minutes in
the future. If he wants to have it expire if the user leaves the site to go
elsewhere, I suspect he's out of luck, because the protocol doesn't support
that (as far as I know).
--
Larry Flynt for Governor!
Bringing dignity back to the Governor's Mansion

Terry Austin
ta*****@hyperbooks.com
Jul 16 '05 #6

P: n/a
Terry Austin wrote:
Matthias Esken <mu************@usenetverwaltung.org> wrote in
news:bi**********@usenet.esken.de:
Terry Austin <ta*****@hyperbooks.com> schrieb:
Cookies have a time to live setting, referred to as the expire time. If
unset, the cookie automatically expires when the browser is closed.


That's OK, but the question was about "leaving the site". It seems like
problem of the definition of "leaving". Does "leave" mean, that you
closed the browser? Does it mean, that you did not show any activity in
the last 5 minutes?


I suspect it would *have* to mean one of those two.

So, if the nameless poster calling himself "gsb" tells us what he means
with "leaving", we might give him something which you could call a
solution.

Cookies could be used for either. If you don't set the expire time, the
session lasts until you close the browser. If you want to set a specific
time, set the expire time for the cookie to (for instance) five minutes in
the future. If he wants to have it expire if the user leaves the site to
go elsewhere, I suspect he's out of luck, because the protocol doesn't
support that (as far as I know).


Just have a sessions table with an expiry time, and extend it by a set number
of seconds (e.g. 480) each time they fetch a page. That way, they're automatically
logged out after (e.g.) 8 minutes of inactivity
Jul 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.