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

  • Home
  • SEARCH
  • 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 1071223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:41:00+00:00 2026-05-16T20:41:00+00:00

In an ASP.NET MVC2 app, we have the standard login action… if (ValidateUser(model.Email, model.Password)

  • 0

In an ASP.NET MVC2 app, we have the standard login action…

if (ValidateUser(model.Email, model.Password)
{
  FormsAuthentication.SetAuthCookie(model.Email, model.RememberMe);
  ...

where the second parameter to SetAuthCookie is createPersistentCookie with the following documentation:

createPersistentCookie
  Type: System.Boolean
    true to create a persistent cookie
    (one that is saved across browser sessions); otherwise, false.

We would like to have the persistent cookie expire after 2 weeks (i.e., a user could return to the site within 2 weeks and not be required to re-authenticate. After that time they would be asked to login again).

How do we set the expiration for the persistent cookie?

  • 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-16T20:41:02+00:00Added an answer on May 16, 2026 at 8:41 pm

    Can you not do this?

    <system.web>
        <authentication mode="Forms">
              <forms timeout="20160"/>
        </authentication>
    </system.web>
    

    The timeout is in minutes.

    This timeout value is irrespective of whether or not you are creating a persistent cookie. It simply says that if you don’t explicitly terminate the cookie (FormsAuthentication.SignOut), it will automatically expire after the given time period.

    In other words, if you do:

    FormsAuthentication.SetAuthCookie(someMembershipName, false);
    

    Will result in the cookie expiring when:

    • The user closes the browser, or
    • The timeout is reached.

    As opposed to if you do:

    FormsAuthentication.SetAuthCookie(someMembershipName, true);
    

    Will result in the cookie only expiring when the timeout is reached.

    HTH

    EDIT:

    Take from MSDN:

    the timeout attribute is described as follows:

    Specifies the time, in integer
    minutes, after which the cookie
    expires. If the SlidingExpiration
    attribute is true, the timeout
    attribute is a sliding value, expiring
    at the specified number of minutes
    after the time that the last request
    was received. To prevent compromised
    performance, and to avoid multiple
    browser warnings for users who have
    cookie warnings turned on, the cookie
    is updated when more than half of the
    specified time has elapsed. This might
    cause a loss of precision. The default
    is “30” (30 minutes).

    Note Under ASP.NET V1.1 persistent
    cookies do not time out, regardless of
    the setting of the timeout attribute.
    However, as of ASP.NET V2.0,
    persistent cookies do time out
    according to the timeout attribute
    .

    In other words, this expiration setting handles the Forms Authentication cookie only.

    The Forms Authentication cookie is a client-side cookie, it has nothing to do with other server-side session you may have (ie a Shopping Cart).

    That Session is expired with the following setting:

    <sessionstate 
          mode="inproc"
          cookieless="false" 
          timeout="20" 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a asp.net mvc2 app. I have been using jquery to do
I'm converting an existing ASP.NET app to MVC2, and I have an existing method
I am building an asp.net MVC2 web app using StructureMap. I have created a
Using Unity in an ASP.Net MVC 2 app I have various dependencies on Controllers
I have an asp.net mvc 2 app. I need to display the same page
I have an asp.net mvc2 application that is using StructureMap 2.6 and NHibernate 3.x.
[NOTE: I'm using ASP.NET MVC2 RC2.] I have URLs like this: /customers/123/orders/456/items/index /customers/123/orders/456/items/789/edit My
After a week of asp.net mvc2, I still haven’t understood the advantages of ViewData.model
I have a ASP.net MVC2 website that was working great when using Visual Studio
I'm trying to write REST-behaviour into my ASP.NET MVC2 app, but I'm having a

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.