Re: new session on each request
Re: new session on each request
- Subject: Re: new session on each request
- From: Chuck Hill <email@hidden>
- Date: Thu, 24 Jan 2008 12:15:17 -0800
On Jan 24, 2008, at 10:40 AM, Zak Burke wrote:
I'm going a little bit mad here. I am working on a new app and
cannot get session management to work correctly. Requests to the
root of the app (.../simple.woa) generate new sessions; requests
generated from within the app (submitting a form) reuse existing
sessions. I must have some basic setting goofed up, but I cannot
figure out what it is.
Mmmmm. Is _is_ how session management is supposed to work.
I am running MacOS 10.4.x; Apache 1.3; WO 5.3; Eclipse 3.3.1.1;
WOLips 3.3.4763.
I have simplified this to the point of creating a brand new
WebObjects Application from the "File > New..." menu and doing
nothing but adding some debugging to Application.java, telling
Session.java to store info in cookies and overriding
domainForIDCookies to return "/",
And that changes things WRT session handling. OK, now I see the
problem. :-)
and adding a form to Main.java that stores some trivial data in the
session.
Submitting the form works fine; I can submit again and again and
the same session is used. I see post URLs like this:
http://localhost/wo/WebObjects/simple.woa/wo/0.4
As soon as I try to re-enter the application, however, by visiting
the root URL,
http://localhost/wo/WebObjects/simple.woa
a new session is created.
Here is the debugging I've added to Application.java:
public WOSession _initializeSessionInContext(WOContext context) {
WOSession session = super._initializeSessionInContext(context);
NSLog.out.appendln("SESSION CREATED IN CONTEXT");
return session;
}
Also add this to your session constructor:
NSLog.out.appendln(new RuntimeException("Session created here"));
public WOSession restoreSessionWithID(String sid, WOContext c) {
NSLog.out.appendln("RESTORING SESSION WITH ID " + sid);
WOSession session = super.restoreSessionWithID(sid, c);
return session;
}
public WOResponse dispatchRequest(WORequest r) {
NSLog.out.appendln("COOKIES: " + r.cookies());
return super.dispatchRequest(r);
}
Change the last line to
WOResponse response = super.dispatchRequest(r);
NSLog.out.appendln("Response COOKIES: " + response.cookies());
return response;
Here is output from the log:
FIRST RQUEST: .../simple.woa/
COOKIES: (<com.webobjects.appserver.WOCookie name=woinst value=
("1") path=null domain=null isSecure=false>,
<com.webobjects.appserver.WOCookie name=wosid value=
("iHZpiQht9xREEO8ObOsAlw") path=null domain=null isSecure=false>)
Initialized session 1: nS0KIh62645y4OOwzlmC0w
SESSION CREATED IN CONTEXT
SECOND REQUEST: form submission from .../simple.woa/
COOKIES: (<com.webobjects.appserver.WOCookie name=woinst value=
("1") path=null domain=null isSecure=false>,
<com.webobjects.appserver.WOCookie name=wosid value=
("nS0KIh62645y4OOwzlmC0w") path=null domain=null isSecure=false>)
RESTORING SESSION WITH ID nS0KIh62645y4OOwzlmC0w
THIRD REQUEST: form submission from .../simple.woa/wo/0.4
COOKIES: (<com.webobjects.appserver.WOCookie name=woinst value=
("1") path=null domain=null isSecure=false>,
<com.webobjects.appserver.WOCookie name=wosid value=
("nS0KIh62645y4OOwzlmC0w") path=null domain=null isSecure=false>)
RESTORING SESSION WITH ID nS0KIh62645y4OOwzlmC0w
FOURTH REQUEST: .../simple.woa/
COOKIES: (<com.webobjects.appserver.WOCookie name=woinst value=
("1") path=null domain=null isSecure=false>,
<com.webobjects.appserver.WOCookie name=wosid value=
("nS0KIh62645y4OOwzlmC0w") path=null domain=null isSecure=false>)
Initialized session 2: 9SVOQyQrdNTKaNlrgK4uyM
SESSION CREATED IN CONTEXT
It's slightly fishy to me that WO is reporting the path and domain
as null, but when I look at the cookie in Firefox those values are
correctly filled in (/ and localhost, respectively).
Those things only have values for cookies being sent _to_ the browser
where they are stored. The browser does not send them to the app so
they are not in cookied received in dispatchRequest.
Besides, the same cookie is correctly read in requests two and
three, when the session is restored.
Any ideas? I'm totally stumped.
What is the default action requestion handler, component or direct
action? That stack trace may show you where this is happening.
Chuck
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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