'Authentication does not save cookie

I have a login form where I should save into cookie the authentication in case the user close and reopen the browser.

I tried with

<authentication mode="Forms" />

With this code, I save the cookie into login

Dim ticket As FormsAuthenticationTicket = New FormsAuthenticationTicket(Login1.UserName, True, 600)
Dim encTicket As String = FormsAuthentication.Encrypt(ticket)
 Response.Cookies.Add(New HttpCookie(FormsAuthentication.FormsCookieName, encTicket))

and here I read the cookie

Dim FormsAuthCookie As HttpCookie = Request.Cookies(FormsAuthentication.FormsCookieName) 
Dim usr As String = FormsAuthCookie.Value
Dim Ticket As FormsAuthenticationTicket = FormsAuthentication.Decrypt(FormsAuthCookie.Value)
  usr = Ticket.Name & ""

The FormsAuthookie.value is always NULL, cannot understand what is wrong



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source