473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Logged in - Session timeout

I use a database to authenticate users. Thier logon info is stored in a
session.
When the session times out it redirects the user back to the login page,
which, when logged in sends them to the secured homepage.

How can I return them to the page they were on when the session timed out,
rather than starting over on the homepage?

Thanks!
Jul 19 '05 #1
3 1731
"Targa" wrote ...
How can I return them to the page they were on when the session timed out,
rather than starting over on the homepage?


Hi Targa,

We wrote something at work that would do this for exactly the same purpose -
dont have the code to hand, but basically you need to send a URL to your
login page - which then redirects the user to that URL...you need to also
take any querystring info with it that you may need....

ie..

Page you're on before time out occurs:

http://www.your-domain.com/surprise.asp?kbid=1234

Now the users times out and you redirect them to your login page, at this
point we created the URL and querystring and put it into a new querystring
value for the redirect, ie...

http://www.your-domain.com/login.asp...e.asp?kbid1234

within your login code you'd need to check to see if URL in the querystring
existed, if it does, takes its value and use that as the redirect instead of
going to your home page.

Somethings we found were that you'll need to URL encode the URL you are
going to redirect to BEFORE you add it to the querystring returning to the
login page, this was because it will other wise take only the first part of
the querystring, and not anything which you may have after &'s etc...

ie..

http://www.your-domain.com/surprise....=1234&sid=5678

when it reads that it'll only use the first part,

ie.

http://www.your-domain.com/surprise.asp?kbid=1234

and assume that the &sid=5678 belonged to the login page (ie, it gets lost)

Use Server.URLEncode before adding the URL to the login pages redirect and
you'll be fine.

Incidentally, we built the URL and querystring from stratch to a new
variable as some of our websites use SSL (ie, https) and others dont (http)
so we wanted to ensure that we always took them to the correct place.

I trust this is of some use...

Regards

Rob
Jul 19 '05 #2
This raise a question though. Can't you use sessions instead of the
quesrystring method, ie, instead of doing
http://www.your-domain.com/login.asp...n.com/surprise
..asp?kbid1234

You have that info in a session, and then simply send them to :
http://www.your-domain.com/login.asp

login.asp will check if that session'ed URL exists, else redirect them to
the homepage?
--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
"Rob Meade" <ro********@NO-SPAM.kingswoodweb.net> wrote in message
news:CY*********************@news-text.cableinet.net...
"Targa" wrote ...
How can I return them to the page they were on when the session timed out,
rather than starting over on the homepage?


Hi Targa,

We wrote something at work that would do this for exactly the same purpose -
dont have the code to hand, but basically you need to send a URL to your
login page - which then redirects the user to that URL...you need to also
take any querystring info with it that you may need....

ie..

Page you're on before time out occurs:

http://www.your-domain.com/surprise.asp?kbid=1234

Now the users times out and you redirect them to your login page, at this
point we created the URL and querystring and put it into a new querystring
value for the redirect, ie...

http://www.your-domain.com/login.asp...n.com/surprise
..asp?kbid1234

within your login code you'd need to check to see if URL in the querystring
existed, if it does, takes its value and use that as the redirect instead of
going to your home page.

Somethings we found were that you'll need to URL encode the URL you are
going to redirect to BEFORE you add it to the querystring returning to the
login page, this was because it will other wise take only the first part of
the querystring, and not anything which you may have after &'s etc...

ie..

http://www.your-domain.com/surprise....=1234&sid=5678

when it reads that it'll only use the first part,

ie.

http://www.your-domain.com/surprise.asp?kbid=1234

and assume that the &sid=5678 belonged to the login page (ie, it gets lost)

Use Server.URLEncode before adding the URL to the login pages redirect and
you'll be fine.

Incidentally, we built the URL and querystring from stratch to a new
variable as some of our websites use SSL (ie, https) and others dont (http)
so we wanted to ensure that we always took them to the correct place.

I trust this is of some use...

Regards

Rob


Jul 19 '05 #3
"Lord Merlin" wrote ...
This raise a question though. Can't you use sessions instead of the
quesrystring method, ie, instead of doing
http://www.your-domain.com/login.asp...n.com/surprise .asp?kbid1234


I guess you could but then wouldn't that just cause exactly the same
problem?

If the users is being returned to the login page because they have timed
out - ie no session variable is now available, then putting the URL of the
page to return them to into a session variable would be pointless as this
would be lost at the same time as all of the other session variables
wouldn't it?

Regards

Rob
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: fr? | last post by:
Hi, i have a website , on wich users have to log in credentials are checked against mysql db some session vars are set during login for use somewhere else in the code. Is there a way to...
15
by: Joshua Beall | last post by:
Hi All, What is the best way to use a cookie to remember a logged in user? Would you store the username and password in two separate cookies? Should the password be plain text? Hashed? Not...
4
by: vesely | last post by:
Hi all, I'm currently relying on logged-in users hitting "logout" (logoff) before they leave, in order to terminate the session. With PHP the session filename is in a cookie that lasts for the...
8
by: gil | last post by:
I'm trying to track how many users are visiting a site and how may are logged in, using application sessions like so: Sub Session_OnStart Session.Timeout = 20 Session("Start") = Now...
2
by: dhnriverside | last post by:
Hi guys I'm trying to create an updated list of which of my AD users are logged onto each computer - there's about 29 computers and we use hotdesking! I'm using Windows Integrated...
8
by: Brendon Bezuidenhout | last post by:
Hey all, Newbie question I'm afraid: Is there a way to see/tell how many users are currently logged into a website at all? Thanks Brendon
3
by: =?Utf-8?B?V2luRGV2?= | last post by:
I have a weird one. My users will be on the system and suddenly get logged out. I have forms authentication turned on with a 1200 minute logout (I raised it that high to test this out.) Session...
7
by: Garry Freemyer | last post by:
I've researched this question on internet, and I've tried a number of things I found to no avail to solve this problem... I work for a company using Visual Studio 2003 to maintain a website for...
2
by: Keith G Hicks | last post by:
asp.net 2.0 I have set my web.config as follows: <forms timeout="30"/(I know that's the default but I may chang it so the line's in there) I also have a few cookies I'm setting on my login...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.