FormsAuthentication.SetAuthCookie Method (String, Boolean)
.NET Framework 3.0
Creates an authentication ticket for the supplied user name and adds it to the cookies collection of the response or the URL.
Namespace: System.Web.Security
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
'Declaration Public Shared Sub SetAuthCookie ( _ userName As String, _ createPersistentCookie As Boolean _ ) 'Usage Dim userName As String Dim createPersistentCookie As Boolean FormsAuthentication.SetAuthCookie(userName, createPersistentCookie)
public static void SetAuthCookie ( String userName, boolean createPersistentCookie )
public static function SetAuthCookie ( userName : String, createPersistentCookie : boolean )
Not applicable.
Parameters
- userName
The name of an authenticated user. This does not have to map to a Windows account.
- createPersistentCookie
true to create a durable cookie (one that is saved across browser sessions); otherwise, false.
| Exception type | Condition |
|---|---|
|
RequireSSL is true and IsSecureConnection is false. |
The SetAuthCookie method adds a forms-authentication ticket to either the cookies collection or the URL if CookiesSupported is false. The forms-authentication ticket supplies forms-authentication information to the next request made by the browser. With forms authentication, you can use the SetAuthCookie method when you want to authenticate a user but still retain control of the navigation with redirects.
Community Additions
ADD
Show: