Confirmed that request.getSession(false)==null for both expired session
requests and anonymous requests, if I have <%@ page session="false" %> in
my pages.
I just figured out the follow which work exactly what I wanted:
boolean hasSessionID =
(request.isRequestedSessionIdFromURL() ||
request.isRequestedSessionIdFromCookie());
if (hasSessionID && !request.isRequestedSessionIdValid()) {
// expired/invalidated session
}
else {
// no session at all
}
> I haven't tested this, but I *think* that a request containing an
> expired session will still return a non-null session object, but a
> different instance to the one that would have been returned pre-timeout.
> But I don't know that for a fact. why not just test it out yourself,
> it's not that hard, just shorten the timeout interval first so that you
> don't have to wait 30 mins to do your test ;)
>
>> -----Original Message-----
>> From: LAM Kwun Wa Joseph [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday 08 December 2004 09:35
>> To: [EMAIL PROTECTED]
>> Subject: RE: How to detect expired session vs. no session?
>>
>>
>> But does it have the same effect for a request with an
>> expired session vs
>> a request with no session at all? I think it will return null in both
>> cases.
>>
>> > if you call request.getSession(false) this will return null if the
>> request is not associated with a request already. the "false" param
>> turns off the default behaviour of creating a new session when none
>> exists.
>> >
>> >> -----Original Message-----
>> >> From: LAM Kwun Wa Joseph [mailto:[EMAIL PROTECTED]
>> >> Sent: Wednesday 08 December 2004 08:23
>> >> To: [EMAIL PROTECTED]
>> >> Subject: How to detect expired session vs. no session?
>> >>
>> >>
>> >> Hi,
>> >>
>> >> How can I tell between a request using an expired session
>> vs a request
>> >> with no session at all? I need to show different messages to
>> >> users being
>> >> kicked due to inactivity and to anonymous users. Thanks!
>> >>
>> >> Regards,
>> >> Joseph Lam
>> >>
>> >>
>> >>
>> >>
>> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail:
>> [EMAIL PROTECTED] For
>> >> additional commands, e-mail: [EMAIL PROTECTED]
>> >>
>> >>
>> >
>> >
>> >
>> >
>> --------------------------------------------------------------
>> ------- To
>> > unsubscribe, e-mail: [EMAIL PROTECTED] For
>> additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED] For
>> additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: [EMAIL PROTECTED] For
> additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]