FormsAuthentication.SetAuthCookie Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates an authentication ticket for the supplied user name and adds it to the cookies collection of the response, or to the URL if you are using cookieless authentication.
Overloads
| Name | Description |
|---|---|
| SetAuthCookie(String, Boolean) |
Creates an authentication ticket for the supplied user name and adds it to the cookies collection of the response, or to the URL if you are using cookieless authentication. |
| SetAuthCookie(String, Boolean, String) |
Creates an authentication ticket for the supplied user name and adds it to the cookies collection of the response, using the supplied cookie path, or using the URL if you are using cookieless authentication. |
Remarks
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.
SetAuthCookie(String, Boolean)
Creates an authentication ticket for the supplied user name and adds it to the cookies collection of the response, or to the URL if you are using cookieless authentication.
public:
static void SetAuthCookie(System::String ^ userName, bool createPersistentCookie);
public static void SetAuthCookie(string userName, bool createPersistentCookie);
static member SetAuthCookie : string * bool -> unit
Public Shared Sub SetAuthCookie (userName As String, createPersistentCookie As Boolean)
Parameters
- userName
- String
The name of an authenticated user. This does not have to map to a Windows account.
- createPersistentCookie
- Boolean
true to create a persistent cookie (one that is saved across browser sessions); otherwise, false.