Re: [Solution] Restoring Session when someone leaves the application
Re: [Solution] Restoring Session when someone leaves the application
- Subject: Re: [Solution] Restoring Session when someone leaves the application
- From: Gerald Hanks <email@hidden>
- Date: Wed, 6 Oct 2004 15:53:22 -0600
What we found was that setting setStoresIDsInURLs(false) and
setStoresIDsInCookies(true) only partially worked and it depended on
what type of action a user took to get back into the application.
Often times there are direct action links that get used to enter an
application at different points such as .../wa/login. These direct
action entry points almost always created a new session regardless of
whether or not there was a session id stored in a cookie. This was
simply a way for us to get around the new session being created for
these direct actions entry points.
--gerald
On Oct 6, 2004, at 8:25 AM, Chuck Hill wrote:
Isn't this the same as adding this to the Session constructor:
// We use cookies to store session and instance number.
setStoresIDsInURLs(false);
setStoresIDsInCookies(true);
Chuck
At 03:16 AM 06/10/2004 -0600, Gerald Hanks wrote:
I am working on a project for a client that needed the ability for
users
that were using his webobjects application to be able to leave the
application and upon return have their active sessions still
accessible.
One reason to be able to leave the application was to view customer
service
docs that are stored in static html, another reason was to be able to
browse to other websites and not have to use the browser back button
to get
back into the application. My solution to the problem was to store the
users session id in a cookie and then override createSessionForRequest
to
see if that cookie exists. If the cookie exists then I try to restore
the
session using that session id, otherwise I create a new session. Here
is
how I overrode the method. Can anyone see anything inherently wrong
with
this approach? It seems to be working well and has been in place now
for
about a month with no problems.
public WOSession createSessionForRequest(WORequest aRequest) {
//NSTimestamp aTime = new NSTimestamp();
WOSession aSession = null;
WOContext aContext = new WOContext(aRequest);
String aSessionID = aRequest.cookieValueForKey("WOSessID");
if((aContext != null) && (aSessionID != null) &&
(!aSessionID.equals(""))) {
//System.out.println("Attempting to restore session: " + aSessionID
+ "
at: " + aTime);
aSession = (Session) restoreSessionWithID(aSessionID, aContext);
}
if(aSession == null) {
//System.out.println("A new session was created at: " + aTime);
aSession = (Session) super.createSessionForRequest(aRequest);
WeakReference aReference = new WeakReference(aSession);
} else {
//System.out.println("An old session was restored at: " + aTime);
}
return aSession;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
village
.net
This email sent to email@hidden<<<<
--
Chuck Hill email@hidden
Global Village Consulting Inc.
http://www.global-village.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden