Vitaliy Fuks wrote:
>I believe your problem may be that if you set a cookie and redirect in
>same request the cookie is ignored.
>You are not inherintly doing that, but because session is expired new
>session is created when user requests that page. At this time, a cookie
>with new session id is sent. At the same time you are doing a redirect
>so that cookie is ignored. When person arrives on redirected page yet
>another session is created (because there is no cookie) and this session
>does not have the value you are looking for.
>If you turn on cookie warnings in your browser you can see if this is
>indeed what is happening.
>You should check if session is not timed out before setting the value.
>If it is, then you could try to avoid the redirect, either by doing
><body onload="document.location='url'"> trick.
>On Mon, 2003-08-11 at 00:32, Randall Smith wrote:
>>I've been having a session problem. It happens when a session times
>>out. Here is the scenario:
>>1. User surfs happily with no problems then waits a while.
>>2. Session times out (I believe).
>>3. User request handled by displatch servlet (Index.py).
>>4. Dispatch servlet (Index.py) sets value in session -
>>5. Dispatch servlet (Index.py) forwards request to view servlet (View.py)
>>6. View servlet (View.py) checks self.session.hasValue(name) and RETURNS
>>It should have just been set by Index.py, but View.py says that it is
>>Note that this problem only arises after a session times out. I've set
>>the session timeout to 1 minute so that I can find the bug. This has
>>haunted me for a while. I would appreciate any insight.
>>This SF.Net email sponsored by: Free pre-built ASP.NET sites including
>>Data Reports, E-commerce, Portals, and Forums are available now.
>>Download today and enter to win an XBOX or Visual Studio .NET.
>>Webware-discuss mailing list
Thank you for your feedback. The solution is still not evident, but
I'm getting closer.
''I believe your problem may be that if you set a cookie and redirect in same request the cookie is ignored.''
So why does it work on the first request when the cookie is first set?
I'm not quite sure what you mean by redirect. I'm not 'redirecting' the
user. The forward() happens on the application server side and is
invisible to the browser. Note that the process works the first time
the cookie is set. So why would it not work when a new cookie is set?
Index.py (Dispatcher) - Receives request, sets session value, forwards
request to View.py
View.py - Reads session value.
On a new visit:
1. User requests Index.py.
2. Index.py sets session variable.
3. Index.py forwards request to View.py (Not a redirect in browser
terms. User has not yet received a response.)
4. View.py reads session variable and produces output to browser.
These steps work on a NEW SESSION and continue to work until the session
times out. After a failed request, a browser REFRESH will cause it to work.