473,385 Members | 1,907 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,385 software developers and data experts.

Expired Session Variables

Is there any way of detecting whether a session variable does not exist
because it expired or because it simply did not exist in the first place?

Thanks
Jul 19 '05 #1
6 2527
Check to see if it's equal to NULL?

"Keith" <@.> wrote in message news:ui**************@TK2MSFTNGP10.phx.gbl...
Is there any way of detecting whether a session variable does not exist
because it expired or because it simply did not exist in the first place?

Thanks

Jul 19 '05 #2

Have a look here:

http://www.4guysfromrolla.com/webtech/102900-1.shtml
"Dominic Marsat" <djmarsatAThotmail.com> wrote in message
news:#N**************@TK2MSFTNGP10.phx.gbl...
Check to see if it's equal to NULL?

"Keith" <@.> wrote in message

news:ui**************@TK2MSFTNGP10.phx.gbl...
Is there any way of detecting whether a session variable does not exist
because it expired or because it simply did not exist in the first place?
Thanks


Jul 19 '05 #3

I don't think this is possible using the Session object alone,
in both cases a new session will be created when your ASP page is called
that will be checking the session.
So you'll have an empty session every time.

I don't know why you'd want to check this, but if you give some more details
maybe there's a way to get what you want.
"Keith" <@.> wrote in message news:ui**************@TK2MSFTNGP10.phx.gbl...
Is there any way of detecting whether a session variable does not exist
because it expired or because it simply did not exist in the first place?

Thanks

Jul 19 '05 #4
I want to do this to check when the username session variable has expired,
and thus their login session has expired. Then I will redirect them to a
different page than if they simplu had not logged in.
"J. Baute" <WU**********@spammotel.com> wrote in message
news:40**********************@news.skynet.be...

I don't think this is possible using the Session object alone,
in both cases a new session will be created when your ASP page is called
that will be checking the session.
So you'll have an empty session every time.

I don't know why you'd want to check this, but if you give some more details maybe there's a way to get what you want.
"Keith" <@.> wrote in message

news:ui**************@TK2MSFTNGP10.phx.gbl...
Is there any way of detecting whether a session variable does not exist
because it expired or because it simply did not exist in the first place?
Thanks


Jul 19 '05 #5
I assume that you want to redirect them to a page asking them to login
again and that you're storing username, password and the session
status in session variables, so.....

login_page.asp
----------------------------------------------------------------------------
--

<form method="post" action="another_page.asp">

<input type="text" name="login_name"><br>
<input type="password" name="login_password"><br>
<input type="submit" value="Submit Info">

</form>

----------------------------------------------------------------------------
--
another_page.asp
----------------------------------------------------------------------------
--

<%

' Get the form data and store in a session variable
Session("login_name") = Request.Form("login_name")
Session("login_password") = Request.Form("login_password")

' Check to see if the input is correct
If Session("login_name") = "keith" and
Session("login_password") = "pass" then
Session("login_status") = "TRUE"
Response.Redirect "another_page_2.asp"
Else
Session("login_status") = ""
Response.Redirect "login_page.asp"
End If

%>

----------------------------------------------------------------------------
--

Every page that requires a user to be logged in should have the
following code.....

<%

If Session("login_status") <> "TRUE" Then
Response.Redirect "login_page.asp"
End If

%>

"Keith" <@.> wrote in message news:eU**************@TK2MSFTNGP10.phx.gbl...
I want to do this to check when the username session variable has expired,
and thus their login session has expired. Then I will redirect them to a
different page than if they simplu had not logged in.
"J. Baute" <WU**********@spammotel.com> wrote in message
news:40**********************@news.skynet.be...

I don't think this is possible using the Session object alone,
in both cases a new session will be created when your ASP page is called
that will be checking the session.
So you'll have an empty session every time.

I don't know why you'd want to check this, but if you give some more

details
maybe there's a way to get what you want.
"Keith" <@.> wrote in message

news:ui**************@TK2MSFTNGP10.phx.gbl...
Is there any way of detecting whether a session variable does not exist because it expired or because it simply did not exist in the first place?
Thanks



Jul 19 '05 #6

"Keith" <@.> wrote in message news:eU**************@TK2MSFTNGP10.phx.gbl...
I want to do this to check when the username session variable has expired,
and thus their login session has expired. Then I will redirect them to a
different page than if they simplu had not logged in.


A common way to do this is simply redirect every expired or not logged in
user to the same login page, cause there isn't really a way to detect the
difference.

Something that could work to some degree is accompany your session cookie
(managed by ASP) with a custom cookie which expires "later" than your
session cookie.
Let's say your session expired after 20 minutes. You could create another
cookie which expires after 30 minutes, which you use to check if the user
logged on in the last 30 minutes. This gives you a timeframe of 10 minutes
where your expired session will be detected. After those 30 minutes, the
user will be considered as "never logged in".

But personnaly I wouldn't bother doing this, I think it will only confuse
the user.

Jul 19 '05 #7

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

Similar topics

4
by: John | last post by:
Could anyone please help me on this?? I have a php script page, which is basically quiz. Visitors (after login in with their email address) are supposed to answer each question, and when they...
3
by: Bob Bedford | last post by:
I've all my site in PHP with POST method, for avoiding most user see what's appening in the variables I pass trough the pages. (as some info shouldn't be visible for most users). What appens...
1
by: Lenny | last post by:
I have application that uses session variables to preserve data between calls Session expiration time is set to 20 min. Sometimes my users getting error 'Session Expired' even right after they...
1
by: szabelin | last post by:
Hello - (1) is there a way to check that session has expired? (2) My session timeout is set to 20 minutes, but I can leave the client overnight and my session is still on next morning- so when...
3
by: Simon | last post by:
Hi all, Any help with this would be much appreciated: I have a site where the session needs to timeout because of security concerns. I want to send the user back to the login page if the...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
6
by: NH | last post by:
How can I warn a user that their session has expired when they click on a button etc?
17
by: Riaan | last post by:
Hi guys! I have an issue that needs urgent resolution. Imagine this scenario: You have: 1 production server running Windows Server 2003, IIS6 and an instance of MSDE 2000. There is an...
4
by: sriram | last post by:
Hello Friends, I am new to this group so big HIIIIIIII to all :) fine i have a serious doubt about session handling in PHP. After 20 min (default time) session getting expired, session values...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.