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 7640615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:42:53+00:00 2026-05-31T08:42:53+00:00

I am writing a Remember My Username Cookie that expires in a custom duration

  • 0

I am writing a “Remember My Username” Cookie that expires in a custom duration of time e.g. one month. I noticed that when I add HttpOnly = true, the expiration changes to session. Why is this? I can’t seem to find any documentation on why this would happen.

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-31T08:42:55+00:00Added an answer on May 31, 2026 at 8:42 am

    I’m adding the following code: Also, now I’m getting a different behaviors than the Title. I’m running this locally against the VS2010 built-in server. It seems to show inconsistent behaviors. I would move the HttpOnly = true before the Expires and after it and it seemed to change behavior until I refreshed the browser page. So, I am assuming everything was fine and never had an issue. In addition, I am moving HttpOnly and Secure flags to the web.config because not all my environments have SSL.


    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket
                                                    (strUserID, //name
                                                     false, //IsPersistent
                                                     24 * 60); // 24 hours
    
    // Encrypt the ticket.
    string encryTicket = FormsAuthentication.Encrypt(ticket);
    
    // Create the cookie.
    HttpCookie userCookie = new HttpCookie("Authentication", encryTicket);
    userCookie.HttpOnly = true;
    Response.Cookies.Add(userCookie);
    
    e.Authenticated = true;
    if (LoginPannelMain.RememberMeSet)
    {
        HttpCookie aCookie = new HttpCookie("email", strUserLogin);
        aCookie.HttpOnly = true;
        aCookie.Expires = DateTime.Now.AddYears(1);
        Response.AppendCookie(aCookie);
    }
    else
    {
        HttpCookie aCookie = new HttpCookie("email", "");
        aCookie.HttpOnly = true;
        Response.AppendCookie(aCookie);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an interactive function that I'd like to have remember the last argument
Writing a JSP page, what exactly does the <c:out> do? I've noticed that the
First: sorry for my poor English writing. I remember that in VB6.0 days, we
Quick background: writing a module. One of my objects has methods that may or
Does anyone have a template for writing a decent equals method - I remember
Writing documentation in html requires some code examples. What to do with characters that
I'm writing a program to count blanks, tabs, and newlines. I remember what the
I'm writing a plugin which creates a custom post_type called dictionary_entry which has several
I am currently writing a CMS and remember someone (it might have been on
When writing Perl scripts I frequently find the need to obtain the current time

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.