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: Chuck Hill <email@hidden>
- Date: Wed, 06 Oct 2004 07:25:21 -0700
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:
.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