We help IT Professionals succeed at work.
Get Started

forms authentication cookie expiration shows : At the end of session

Last Modified: 2012-09-05
When I open my website and Go to Developer tools (on IE9)
and view cookies I see

The cookie name I set for the forms autentication cookie, but the Expiration shows : At the end of the session. How can I make the cookie expire on the time I set in code here

<forms name=".dsa" loginUrl="frmStartLogin.aspx"  domain =".wsifb.com" defaultUrl="frmStart.aspx" protection="All" timeout="60" path="/" slidingExpiration="true"/>

  If isPersistent Then
                    intTimeoutMinutes = 43200 '30 days
                    intTimeoutMinutes = 1440
                End If
                'create auth cookie
                tkt = New FormsAuthenticationTicket(1, strUserName, DateTime.Now(), DateTime.Now.AddMinutes(intTimeoutMinutes), isPersistent, strUserName)
                cookiestr = FormsAuthentication.Encrypt(tkt)
                ck = New HttpCookie(FormsAuthentication.FormsCookieName(), cookiestr)
                If isPersistent Then
                    ck.Expires = tkt.Expiration
                End If
                ck.Path = FormsAuthentication.FormsCookiePath()
                'write auth cookie to client PC
Watch Question
Practice Manager
This problem has been solved!
Unlock 1 Answer and 11 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE