session is nothing

J

Joel Brabant

How can I know if a user session had timed out ?

I always get an error in my asp page when I try to access
my session variable if it timed out.

Thank You.
 
R

Ray at

What error? What code? Any time you hit your asp page, there's a session,
whether it's the same one that you had five seconds prior, or a new one.

Ray at work
 
J

Joel Brabant

The error is : object required....

The session has timed out.
For sure my session("blabla") is nothing... I know that.

But howcome it crashes when I use

If session("blabla") is nothing then
...
end if

!!!

Joel Brabant
Developer
Tembec Inc.
 
R

Ray at

P.S. Is Nothing only works on variables that have been defined as object
variables. i.e.

On Error Resume Next
Dim x
response.write "x is nothing?<br>"
Response.Write x is nothing
response.write "<br>" & err.description
err.clear
response.write "<hr>"


set x = createobject("adodb.connection")
response.write "x is now an object<br>"
response.write x is nothing
response.write err.description & "<br>"
err.clear
response.write "<hr>"


response.write "x has been destroyed<br>"
set x = nothing
response.write x is nothing
response.write err.description


If this were VB code and you did:
dim x as object

It wouldn't generate the error.

Ray at work




''that will gen
 
B

Bob Barrows

Joel said:
The error is : object required....

The session has timed out.
For sure my session("blabla") is nothing... I know that.

But howcome it crashes when I use

If session("blabla") is nothing then
..
Because, unless you are storing an object in session("blabla"),
session("blabla") will not be an object. Only objects can be Nothing.

I usually do this:

If len(session("blabla")) = 0 then

--
HTH,
Bob Barrows - Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
J

Joel Brabant

Session("oAppUser") is in fact an object that was returned by my vb code
like this:

Set oAppTDE = Server.CreateObject("AppTDE.TDEManager")
Set Session("oAppUser")=oAppTDE.Login(cstr(sUsername),cstr(sPassword))
Set oAppTDE = Nothing

Don't worry ! I know, we are not suppose to store objects in session
variables....but that object has just a couple of properties that's it.

Thank you all for your help.

Joel Brabant
Developer
Tembec Inc.
 
B

Bob Barrows

Joel said:
Session("oAppUser") is in fact an object that was returned by my vb
code like this:

Set oAppTDE = Server.CreateObject("AppTDE.TDEManager")
Set Session("oAppUser")=oAppTDE.Login(cstr(sUsername),cstr(sPassword))
Set oAppTDE = Nothing

Don't worry ! I know, we are not suppose to store objects in session
variables....but that object has just a couple of properties that's
it.
What the object stores is not the problem. The problem is whether or not the
object is free-threaded. If it was created in VB, then it is not
free-threaded, and storing it in Session is not recommended.

So, you need to find out if the session variable exists, and if it does
exist, it will contain an object.

The first step is to use IsObject to determine if it is an object.

If IsObject(Session("oAppUser") then
if not Session("oAppUser") is nothing then


--
HTH,
Bob Barrows - Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top