• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Session Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Session Question


  • Subject: Re: Session Question
  • From: Gerald Hanks <email@hidden>
  • Date: Wed, 9 Feb 2005 13:34:51 -0700

Hello Chuck,

I am the one that actually wrote this code piece a while back when I was trying to solve the problem addressed in "Radar #2274039". Whenever a client would access the app using the front door, a new session would always be created. I used the suggestion from Stephane and included this in my Application.java:

public boolean shouldRestoreSessionOnCleanEntry(WORequest aRequest) {
	return true;
}

This solves the problem of clients getting a new session using the front door but creates another problem. Now when a client leaves the app and the session times out, a session restore exception is thrown everytime. Even when entering the application through the front door. When a client leaves the application for a couple of hours they naturally expect to get the application main page not a session timed out page when they access the app again. You can see that that is what I was attempting to control with the code sent back to me by Jan. When entering the application I wanted to restore the session even when the session was dropped because shouldRestoreSessionOnCleanEntry() was returning the default of false. By overriding the createSessionForRequest I could ensure that the session was always restored if it still existed. Even if the application was going to create a new session. As you have seen from others who have posted questions regarding this piece of code, it may be causing a problem with some sessions never expiring. I have never been able to verify this error. I assumed however from your insistence that this code should never be needed that there must be a better way to solve the issue noted in "Radar #2274039 - IDs in Cookies are dropped at the front door of applications."

How did you solve this problem? I am sure that many on this board (especially those that have used my code snippet) would be happy to know of a better solution to the problem. Thanks in advance.

--gerald

On Feb 8, 2005, at 4:12 PM, Chuck Hill wrote:

I've seen this code floating around the list, but I can't figure out when it would be needed. I've never seen the need. What situation is this supposed to be for?

Chuck

On Feb 8, 2005, at 2:30 PM, Jan Willem Luiten wrote:

Hello Gerald,

Add the following method to your application class:

public WOSession createSessionForRequest(WORequest aRequest) {
//NSTimestamp aTime = new NSTimestamp();
WOSession aSession = null;
WOContext aContext = new WOContext(aRequest);
String aSessionID = aRequest.cookieValueForKey("wosid");
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;
}


Kind regards,

Jan Willem Luiten.

_______________________________________________ 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
References: 
 >Session Question (From: Gerald Hanks <email@hidden>)
 >Re: Session Question (From: Jan Willem Luiten <email@hidden>)
 >Re: Session Question (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: Handling exceptions in dispatchRequest
  • Next by Date: Re: Direct Action App Editing Context management?
  • Previous by thread: Re: Session Question
  • Next by thread: Re: Session Question
  • Index(es):
    • Date
    • Thread