Re: Controlling Sessions
Re: Controlling Sessions
- Subject: Re: Controlling Sessions
- From: David LeBer <email@hidden>
- Date: Mon, 17 Nov 2008 18:09:00 -0500
On 17-Nov-08, at 5:49 PM, Awbrey Hughlett wrote:
I was wondering how to control sessions using direct actions and
WORedirect. Right now this is how my code looks ...
public WORedirect homeButton() {
if (context().session() != null) {
if (((Session)session()).authenticatedUser() != null) {
((Session)session()).setAuthenticatedUser(null);
session().terminate();
}
}
String url = context().directActionURLForActionNamed("default",
null);
url = url.replaceAll("&", "&");
WORedirect redirect = new WORedirect(context());
redirect.setUrl(url);
return redirect;
This works as long as the session being tested for null has not
timed out. This bit of code is in a component at the top of every
one of my pages. It controls what happens is a user is logged in. If
that particular user in the session is logged in, I want them to
automatically be logged out and sent to their intended destination
where as here the destination is the home screen. The problem I am
having is that when the session times out while the user is still
logged in, the button takes them to the session timed out page.
What I want to do:
* When the WORedirect is called, I want the first if statement to
test whether there is an active session. If there is, then I want to
set the authenticated user to null, terminate the current session if
there was a user authenticated, and then redirect them back to the
default page.
* If there is not an active session, I want to skip everything
about the user, create a session, and redirect to the default page.
* I don't ever want the user to see any kind of 'session timed out'
page.
How could I go about doing this?
Why don't you get rid of the redirect change the link on the page to
call a da directly and put that logic into the directAction?
;david
--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site: http://codeferous.com
blog: http://davidleber.net
profile: http://www.linkedin.com/in/davidleber
twitter: http://twitter.com/rebeld
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org
_______________________________________________
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