Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6143457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:31:32+00:00 2026-05-23T18:31:32+00:00

I implemented Remember me functionality in my web app. I did this using a

  • 0

I implemented “Remember me” functionality in my web app. I did this using a cookie that contains username/password encrypted using RSA.

I add the cookie when I login; if then I logout (without closing browser) the cookie is read ok and in the login page I see username/pass already typed.
But if I close the browser; or close tab and run the application again, when the cookies are read, the only cookie that is read is the JSESSIONID. the cookie with the credentials is not in the array returned by
((HttpServletRequest)facesContext.getExternalContext().getRequest()).getCookies(­);
even though I can see it in the browser. why is that?

This is the code that creates the cookie:

String credentials = username + "?" + password;
Cookie c = CookieHandler.getInstance().createCookie("vtcred", credentials, rememberMe);
FacesContext facesContext = FacesContext.getCurrentInstance();
((HttpServletResponse) facesContext.getExternalContext().getResponse()).addCookie(c);

and method createCookie:

public Cookie createCookie(String name, String value, boolean rememberMe) {
        value = encript(value);
        Cookie credCookie = new Cookie(name, value);
        credCookie.setHttpOnly(true);
        if(rememberMe) {
            credCookie.setMaxAge(86400);
        }
        else {
            credCookie.setMaxAge(0);
        }
        return credCookie;
    }

Edit: I am setting the cookie’s max age to one day; and in the browser I can see that the cookie expires tomorrow, so that’s not the problem

Thanks in advance,
Damian

edit2: this is very odd, but it seems to be working now. I’ll keep testing it and notify. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:31:33+00:00Added an answer on May 23, 2026 at 6:31 pm

    I found why sometimes a cookie is not read. It has to do with the path attribute.

    If anyone is having this issue, set the path of the cookie, like this:

    Cookie c = new Cookie("name", "value");
    cookie.setMaxAge(86400);
    cookie.setPath("/");
    

    Regards

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented remember me option in my asp.net webform by using this, protected
I have successfully implemented Remember Me functionality in my application. Only I want to
I've implemented an ASP.NET web application that supports 5 different languages. The web application
I'm using WCF to implement a web service. This web service requires a 'ping'
I have implemented spring security's remember me feature in our app, the way i
i found some samples that implements remember me functionality by just <remember-me/> and other
I just implemented a remember me feature for a user login on a website.
Implemented a generic repository with several Methods. One of those is this: public IEnumerable<T>
I implemented OpenID support for an ASP.Net 2.0 web application and everything seems to
What is the best way to implement ' remember me ' functionality on an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.