M
masoud bayan
I have a forms authenticated asp.net web application. in login page there is a check box which when is checked user name should be kept for next login time.
I know there is an option as --- FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, chkRemember.checked) ----- to persist cookie across sessions but my application is different. I just want to save user name in a cookie (not authorized user) in order that when he opens browser and redirect his browser to login page he has not to enter his user name in user name text box. to do this in an non forms authentication based app I used to just add following code in login page:
Dim objCookie As HttpCookie
If chkPersist.Enabled Then
objCookie = New HttpCookie("strUsername", txtUserName.Text)
objCookie.Expires = DateAdd("yyyy", 1, Now())
Else
objCookie = New HttpCookie("strUsername", "")
objCookie.Expires = Now
End If
Response.Cookies.Add(objCookie)
and also in the beginning of login page whenever always check for this cookie and retrieve user name and show in text box.
but now with forms authentication when I add such a cookie to cookies I can not access it later.
Please let me have your experience or comments in this regards.
Thanks
I know there is an option as --- FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, chkRemember.checked) ----- to persist cookie across sessions but my application is different. I just want to save user name in a cookie (not authorized user) in order that when he opens browser and redirect his browser to login page he has not to enter his user name in user name text box. to do this in an non forms authentication based app I used to just add following code in login page:
Dim objCookie As HttpCookie
If chkPersist.Enabled Then
objCookie = New HttpCookie("strUsername", txtUserName.Text)
objCookie.Expires = DateAdd("yyyy", 1, Now())
Else
objCookie = New HttpCookie("strUsername", "")
objCookie.Expires = Now
End If
Response.Cookies.Add(objCookie)
and also in the beginning of login page whenever always check for this cookie and retrieve user name and show in text box.
but now with forms authentication when I add such a cookie to cookies I can not access it later.
Please let me have your experience or comments in this regards.
Thanks