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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:32:39+00:00 2026-05-31T03:32:39+00:00

When a valid user logs into the system and closes the browser without logging

  • 0

When a valid user logs into the system and closes the browser without logging out, it occasionally (i.e. not immediately after but in the next day) prevents the user to login back into the system throwing the following:

Error: 403 – Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied.

This question refers to the same problem but in his solution, he decided not to use persistent cookies by passing false as a parameter when creating the FormsAuthenticationTicket, which is not the desired solution.

This is how I am creating the cookie:

private void createCookie(string username, int customerID, bool persist)
{
    HttpCookie cookie = FormsAuthentication.GetAuthCookie(username, persist);
    cookie.Expires = DateTime.Now.AddHours(12);
    var ticket = FormsAuthentication.Decrypt(cookie.Value);
    var userData = customerID.ToString();
    var newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, userData);
    cookie.Value = FormsAuthentication.Encrypt(newTicket);
    Response.Cookies.Add(cookie);
}

Any ideas on how to solve this?

  • 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-31T03:32:40+00:00Added an answer on May 31, 2026 at 3:32 am

    There is no inherent problem with including your own userData in the auth cookie.
    In one of our websites we use the asp.net login control, and add the following event listener with much success:

        protected void Login1_LoggedIn(object sender, EventArgs e)
        {
            //... unimportant code left out
    
            //Update the users ticket with custom userInfo object
            string userData = userInfo.Id.ToString("N");
            HttpCookie cookie = Response.Cookies.Get(FormsAuthentication.FormsCookieName);
            FormsAuthenticationTicket oldTicket = FormsAuthentication.Decrypt(cookie.Value);
            FormsAuthenticationTicket newTicket =
                new FormsAuthenticationTicket(
                    oldTicket.Version,
                    oldTicket.Name,
                    oldTicket.IssueDate,
                    oldTicket.Expiration,
                    oldTicket.IsPersistent,
                    userData,
                    oldTicket.CookiePath);
            cookie.Value = FormsAuthentication.Encrypt(newTicket);
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a directory protected using htpasswd called /secret A valid user logs
How do you detect when a user logs out using the ASP.Net 4 session
I'm trying to tracking valid user Ids in my Java servlet, can I implement
What are the valid characters for a user name when using the SQL provider
Checking if a user input is a valid date or a valid date +
I have an aspx page,where the user will enter a valid image url(ex :
I need to determine if a user-supplied string is a valid file path (i.e.,
I once knew a website where the user could generate the little W3C valid
With valid HTML the following finds the object as expected in all browsers but
When a user logs in to my website, I redirect him to a https://

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.