Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. HELP - Forms Auth Cookie persists after closing browser...

HELP - Forms Auth Cookie persists after closing browser...

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netsecurityhelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Grapes R Fun
    wrote on last edited by
    #1

    Hi Guys, I need your help :-) I have forms authentication setup on an asp.net portal. Even though I have the auth ticket to "NOT" persist, it does so after closing the browser... I have tried all the tricks with FormsAuthentication.SignOut() but still no cure. Is there a way I could get rid of the forms auth cookie when the client browser is closed?? Many thanks in advance :-)

    Green Grape

    L 1 Reply Last reply
    0
    • G Grapes R Fun

      Hi Guys, I need your help :-) I have forms authentication setup on an asp.net portal. Even though I have the auth ticket to "NOT" persist, it does so after closing the browser... I have tried all the tricks with FormsAuthentication.SignOut() but still no cure. Is there a way I could get rid of the forms auth cookie when the client browser is closed?? Many thanks in advance :-)

      Green Grape

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Grapes-R-Fun wrote:

      Even though I have the auth ticket to "NOT" persist

      How? That's the first thing I would check. If there is a mechanism that is supposed to result in the browser not caching the cookie and it's not working then the first thing I would suspect is my implementation of the mechanism.

      G 1 Reply Last reply
      0
      • L led mike

        Grapes-R-Fun wrote:

        Even though I have the auth ticket to "NOT" persist

        How? That's the first thing I would check. If there is a mechanism that is supposed to result in the browser not caching the cookie and it's not working then the first thing I would suspect is my implementation of the mechanism.

        G Offline
        G Offline
        Grapes R Fun
        wrote on last edited by
        #3

        Mike, I don't know what's causing it to behaive this way... I'm running out of options! This is my code:

        if (_IsAuthenticated)
        {
        FormsAuthenticationTicket _ticket = new FormsAuthenticationTicket(1,
        this.userHandletbx.Text + "_" + DateTime.Now.ToString(),
        DateTime.Now,
        DateTime.Now.AddMinutes(30),
        false, // Value of IsPersistent property
        String.Empty,
        FormsAuthentication.FormsCookiePath);

          string \_encryptedTicket = FormsAuthentication.Encrypt(\_ticket);
        
          HttpCookie \_authCookie = new HttpCookie(
                        FormsAuthentication.FormsCookieName,
                        \_encryptedTicket);
        
          \_authCookie.Secure = false;
        
          Response.Cookies.Add(\_authCookie);
        
          FormsAuthentication.RedirectFromLoginPage(this.userHandletbx.Text, true);
        

        }

        And this is my web.config:

        <authentication mode="Forms">
        <forms loginUrl="Login.aspx"
        name=".ASPXFORMSAUTH"
        protection="All"
        path="/"
        timeout="40"
        defaultUrl="Home.aspx"
        enableCrossAppRedirects="false"
        slidingExpiration="true">

        </forms>
        

        </authentication>

        ...and no matter where I stick

        FormsAuthentication.SignOut()

        it doesn't kill that darn cookie! Am I missing something? Is this a blonde moment I'm having? ;P Thanks for your help, by the way.

        Green Grape

        L 1 Reply Last reply
        0
        • G Grapes R Fun

          Mike, I don't know what's causing it to behaive this way... I'm running out of options! This is my code:

          if (_IsAuthenticated)
          {
          FormsAuthenticationTicket _ticket = new FormsAuthenticationTicket(1,
          this.userHandletbx.Text + "_" + DateTime.Now.ToString(),
          DateTime.Now,
          DateTime.Now.AddMinutes(30),
          false, // Value of IsPersistent property
          String.Empty,
          FormsAuthentication.FormsCookiePath);

            string \_encryptedTicket = FormsAuthentication.Encrypt(\_ticket);
          
            HttpCookie \_authCookie = new HttpCookie(
                          FormsAuthentication.FormsCookieName,
                          \_encryptedTicket);
          
            \_authCookie.Secure = false;
          
            Response.Cookies.Add(\_authCookie);
          
            FormsAuthentication.RedirectFromLoginPage(this.userHandletbx.Text, true);
          

          }

          And this is my web.config:

          <authentication mode="Forms">
          <forms loginUrl="Login.aspx"
          name=".ASPXFORMSAUTH"
          protection="All"
          path="/"
          timeout="40"
          defaultUrl="Home.aspx"
          enableCrossAppRedirects="false"
          slidingExpiration="true">

          </forms>
          

          </authentication>

          ...and no matter where I stick

          FormsAuthentication.SignOut()

          it doesn't kill that darn cookie! Am I missing something? Is this a blonde moment I'm having? ;P Thanks for your help, by the way.

          Green Grape

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          Grapes-R-Fun wrote:

          ...and no matter where I stick FormsAuthentication.SignOut() it doesn't kill that darn cookie! Am I missing something?

          First two obvious questions are: 1) Is the code executing? The function can't work if it is never being called. 2) Have you followed all the directions of the documentation for the SignOut method?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups