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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:57:48+00:00 2026-06-14T06:57:48+00:00

Can someone explain to me how ASP.NET Forms Authentication works because I don’t seem

  • 0

Can someone explain to me how ASP.NET Forms Authentication works because I don’t seem to get it and I keep getting signed out.

As it stands, I have username, password and a “Keep me signed in” checkbox. From these values I’m creating a ticket and cookie, as follows:

    // Create ticket
    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,email,DateTime.UtcNow,DateTime.UtcNow.AddMinutes(30),remember,String.Empty);

    // Encrypt ticket
    string cookie_contents = FormsAuthentication.Encrypt(ticket);

    // Create cookie
    HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName,cookie_contents);

    if (remember) {
        cookie.Expires = DateTime.UtcNow.AddDays(90);
    }

    cookie.Path = FormsAuthentication.FormsCookiePath;
    cookie.Secure = true;

    // Add cookie to response
    Response.Cookies.Add(cookie); 

I would expect with this code that I can sign in to my website and assuming I check “Keep me signed in” that I stay signed in, for at least 90 days?

However what I am seeing is that I’m being signed out at least 30 minutes after initial login (which is the time set aside for the ticket?).

What is the difference between cookie expiration and ticket expiration and how do I keep myself signed. Do I need to set 90 days to both cookie and ticket?

  • 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-14T06:57:49+00:00Added an answer on June 14, 2026 at 6:57 am

    Don’t manipulate the cookie directly if you can avoid it. You can use FormsAuthentication.SetAuthCookie(username, persistent) to sign a user in. Persistent here means “don’t use session cookie”.

    You should then specify the cookie expiry in web.config under

     <system.web>
       <authentication mode="Forms">
                 <forms timeout="50000000" slidingExpiration="true"/>
       </authentication>
     </system.web>
    

    where sliding expiration means that the cookie will be renewed for each request. Timeout is in minutes, so the example is pretty high 🙂

    Take a look at this question and the link to Scott Gu’s blog: Forms Authentication Cookie Expiration

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

Sidebar

Related Questions

Can someone explain how the ASP.NET Web Development Server work? I don't have IIS
Can someone explain exactly how/when an ObjectDataSource fires? I have an ASP.NET page, with
Excuse the 'noob' question, but can someone please explain the way ASP.NET's buttons work.
Can someone explain this paragraph on page 258(Pro ASP.NET MVC 1.0 Chapter 6: Using
Can someone explain me about SQL Server Reporting Service and using it in ASP.net?
Can someone explain the format for ASP.NET MVC controllers? They look like this: public
Can someone please explain to me how you add jquery libraries to an asp.net
Can someone explain me why this works: select val1, val2, count(case when table2.someID in
Can someone explain why, in this situation, scandir is getting my directory, but the
Can someone explain how the organisation of classes in Pharo works in different versions

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.