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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:21:29+00:00 2026-06-09T04:21:29+00:00

I am generating a FormsAuthentication ticket, and storing it in a cookie, which I

  • 0

I am generating a FormsAuthentication ticket, and storing it in a cookie, which I use with the MVC AuthorizeAttribute to provide authorization. Right now, I’ve got it so the cookie doesn’t expire if I have a “stay signed in” checkbox checked, (I’m just changing the cookie.expires to now + 1 year, for testing purposes, when they’ve got it checked to stay signed in).

However, even though I set that the cookie is persistent when I create the ticket, the ticket still stops working after the timeout period.

Here’s the code where I create the AuthTicket:

var now = DateTime.UtcNow.ToLocalTime();
FormsAuthenticationTicket authTicket = new System.Web.Security.FormsAuthenticationTicket(1, username, now, now.Add(FormsAuthentication.Timeout), rememberMe, username, FormsAuthentication.FormsCookiePath);
string encryptedTicket = System.Web.Security.FormsAuthentication.Encrypt(authTicket);
return encryptedTicket;

That’s the same encryptedTicket that I set as a cookie. Anyone know how I can keep this ticket allowed past the FormsAuthentication timeout? Do I just have to manually mess with the FormsAuthentication Timeout time?

  • 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-06-09T04:21:32+00:00Added an answer on June 9, 2026 at 4:21 am

    The amount of time the cookie sticks around is not the same as how long the login will stay valid. Basically, the persistent cookie is a ‘should this cookie stick around after the browser closes’ and is independent from how long is this login valid. You can use this to store the username for instance so that a user does not have to re-enter this information when they come back.

    If the cookie is valid, but the login has expired within the cookie, you will need to login again. If you want your login to last longer, you will need to extend the time on your <forms> tag in the web.config or you can do this in code, but then you need to recompile if you want to lengthen/shorten the expiration times.

    Here are some sites that explain a little further about these concepts:

    http://software-security.sans.org/blog/2012/04/05/forms-authentication-remember-me-its-hard-not-too

    Cookie Confusion with FormsAuthentication.SetAuthCookie() Method

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

Sidebar

Related Questions

while generating DAO classes using hbm2dao, is it possible to provide a custom package
In generating a select tag for a Boolean value, I use the following code:
While generating XML files with SimpleXml, I got challengefull problem. I want to make
When generating dynamic content, which way is better to simply create the HTML and
I am generating data validation javascript in an Asp.Net MVC 3 application with the
In generating Windows DLL dynamic libraries, you are asked to declare which functions should
I have multiple threads generating log entries and I use the logback SiftingAppender to
When generating hashcodes for a class, is it ok to use the hashcodes of
When generating setters and getters in Eclipse one of the options is to use
am generating unique api keies using this function and storing into database. strtoupper( md5(

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.