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
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
.
Exceptions
RequireSSL is true
and IsSecureConnection is false
.
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
Applies to
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
The name of an authenticated user.
- createPersistentCookie
- Boolean
true
to create a durable cookie (one that is saved across browser sessions); otherwise, false
.
- strCookiePath
- String
The cookie path for the forms-authentication ticket.
Exceptions
RequireSSL is true
and IsSecureConnection is false
.
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
- ASP.NET Web Application Security
- Explained: Forms Authentication in ASP.NET 2.0
- How To: Use Membership in ASP.NET 2.0
Applies to
Atsauksmes
https://aka.ms/ContentUserFeedback.
Drīzumā: 2024. gada laikā mēs pakāpeniski pārtrauksim izmantot “GitHub problēmas” kā atsauksmju par saturu mehānismu un aizstāsim to ar jaunu atsauksmju sistēmu. Papildinformāciju skatiet:Iesniegt un skatīt atsauksmes par