FormsAuthentication.SetAuthCookie FormsAuthentication.SetAuthCookie FormsAuthentication.SetAuthCookie FormsAuthentication.SetAuthCookie Method

Definition

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

SetAuthCookie(String, Boolean) SetAuthCookie(String, Boolean) SetAuthCookie(String, Boolean) 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) SetAuthCookie(String, Boolean, String) SetAuthCookie(String, Boolean, String) 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) SetAuthCookie(String, Boolean) SetAuthCookie(String, Boolean) 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 String String String

The name of an authenticated user. This does not have to map to a Windows account.

createPersistentCookie
Boolean Boolean Boolean Boolean

true to create a persistent cookie (one that is saved across browser sessions); otherwise, false.

Exceptions

Remarks

The SetAuthCookie method adds a forms-authentication ticket to either the cookies collection, or to 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.

See Also

SetAuthCookie(String, Boolean, String) SetAuthCookie(String, Boolean, String) SetAuthCookie(String, Boolean, String) 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.

public:
 static void SetAuthCookie(System::String ^ userName, bool createPersistentCookie, System::String ^ strCookiePath);
public static void SetAuthCookie (string userName, bool createPersistentCookie, string strCookiePath);
static member SetAuthCookie : string * bool * string -> unit
Public Shared Sub SetAuthCookie (userName As String, createPersistentCookie As Boolean, strCookiePath As String)
Parameters
userName
String String String String

The name of an authenticated user.

createPersistentCookie
Boolean Boolean Boolean Boolean

true to create a durable cookie (one that is saved across browser sessions); otherwise, false.

strCookiePath
String String String String

The cookie path for the forms-authentication ticket.

Exceptions

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.

See Also

Applies to