OK. Regarding the NULL thing, I added this:
            Cookie userIdCookie = new
Cookie(EurekifyWebApplication.COOKIE_LOGIN_ID, userId);
            userIdCookie.setMaxAge((int) Duration.days(30).seconds());

and then:
getWebRequestCycle().getWebResponse().addCookie(userIdCookie);

What about the logic itself? Is this the correct way?
And I know that this is a security issue. I am avoiding it for now.

On Sun, Jun 22, 2008 at 12:12 PM, Eyal Golan <[EMAIL PROTECTED]> wrote:

> Hi,
> I am trying to create a way that the Wicket application will remember the
> user that was logged in.
> (like gmail remembers my id when I go to it if I didn't log out).
>
> I am using cookies for that.
> In the Login page I have this:
>         *Cookie idCookie =
> getWebRequestCycle().getWebRequest().getCookie("loginId");
>         Cookie passCookie =
> getWebRequestCycle().getWebRequest().getCookie("loginPass");*
>         if (idCookie != null && passCookie != null) {
>             String cookieUserId = idCookie.getValue();
>             String cookieUserPass = passCookie.getValue();
>             if (cookieUserId != null && cookieUserPass != null) {
>                 PortalSession session = (PortalSession) getSession();
>                 session.setCredentials(cookieUserId, cookieUserPass);
>                 redirectToHomePage();
>             }
>         }
>
> Otherwise, in the login form submission I have this:
>             String userId = getUserId();
>             PortalSession session = (PortalSession) getSession();
>             session.setCredentials(userId, getPassword());
>             getWebRequestCycle().getWebResponse().addCookie(new
> Cookie("loginId", userId));
>             getWebRequestCycle().getWebResponse().addCookie(new
> Cookie("loginPass", getPassword()));
>             if (!continueToOriginalDestination()) {
>                 logger.info("continueToOriginalDestination returned false.
> Redirecting to PortalWebPage");
>                 redirectToHomePage();
>             }
>
> I checked in FF and saw the cookies.
> The problem is that if I close IE7 or FF, the open it.
> In the login page, I get null for the cookies (the bold lines above).
>
> 1. Is this the correct way for doing that?
> 2. Do I get null in the cookies retrieve?
>
> Thanks,
> --
> Eyal Golan
> [EMAIL PROTECTED]
>
> Visit: http://jvdrums.sourceforge.net/
> LinkedIn: http://www.linkedin.com/in/egolan74




-- 
Eyal Golan
[EMAIL PROTECTED]

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

Reply via email to