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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:14:44+00:00 2026-06-15T08:14:44+00:00

I have a login system using FormsAuthentication that for some reason is logging me

  • 0

I have a login system using FormsAuthentication that for some reason is logging me out when closing and opening the browser. Here is how I have setup my login code:

            FormsAuthenticationTicket ticket;

                ticket = new FormsAuthenticationTicket(1, tbUsername.Text, DateTime.Now, DateTime.Now.AddYears(1), true, string.Empty, FormsAuthentication.FormsCookiePath);

            string encryptedTicket = FormsAuthentication.Encrypt(ticket);

            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
            cookie.HttpOnly = true;

            //Add the cookie to the request
            Context.Response.Cookies.Add(cookie);

As you can see I have set the cookie to be persistent across sessions. Here is my web.config part:

<authentication mode="Forms">
  <forms slidingExpiration="false" loginUrl="~/Login.aspx" name="BOIGAUTH" defaultUrl="~/Admin/Settings.aspx"/>
</authentication>

Also, SessionState is disabled on this particular application. Anyone know what is wrong?

Btw leaving the application browser on for more than 2 hours kept me logged in even though I did not interact with the website. The cookie is only being lost when closing the browser.

  • 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-15T08:14:45+00:00Added an answer on June 15, 2026 at 8:14 am

    If you don’t set expiration on cookie it will be browser-session-only cookie and disappear after you close all instances of browser.

    You need to set some expiration on your cookie for it to be persistent with Expires property.

    HttpCookie cookie = new HttpCookie(
       FormsAuthentication.FormsCookieName, encryptedTicket);
    cookie.HttpOnly = true;
    cookie.Expires = DateTime.Now.AddMinutes(1000);
    

    Side note: make sure your browser is not configured to clear all cookies on close.

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

Sidebar

Related Questions

Assume that I have login to system using PHP + MySQL, then, after I
I have a login system, and while logged in, if I refresh the browser,
My problem in fairly simple. I have a login system constructed using php, mysql
I have a CakePHP website with its own login system using the Auth component.
I want to create simple login system using the SQLLIte I have created the
Im looking to have a login system on my asp.net mvc website and at
We have a typical web-based login system. We want customers to have the ability
This aspect of my login system works just fine if I have the return
I have a database system developed in mysql and php, with a login system
I am working on a login system for a client and I have run

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.