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

定義

為所提供的使用者名稱建立驗證票證,並將該票證加入至回應的 Cookie 集合,或加入至 URL (若使用的是 Cookieless 驗證)。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) SetAuthCookie(String, Boolean) SetAuthCookie(String, Boolean) SetAuthCookie(String, Boolean)

為所提供的使用者名稱建立驗證票證,並將該票證加入至回應的 Cookie 集合,或加入至 URL (若使用的是 Cookieless 驗證)。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)

為所提供的使用者名稱建立驗證票證,並使用提供的 Cookie 路徑或使用 URL (若是使用 Cookieless 驗證),將該票證加入至回應的 Cookie 集合。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.

備註

false如果SetAuthCookie 為,方法會將表單驗證票證加入cookie集合或URL。CookiesSupportedThe 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. 使用表單驗證時, 您可以SetAuthCookie在想要驗證使用者, 但仍保有使用重新導向的導覽控制權時, 使用方法。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)

為所提供的使用者名稱建立驗證票證,並將該票證加入至回應的 Cookie 集合,或加入至 URL (若使用的是 Cookieless 驗證)。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)

參數

userName
String String String String

已驗證使用者的名稱。The name of an authenticated user. 這不必對應到 Windows 帳戶。This does not have to map to a Windows account.

createPersistentCookie
Boolean Boolean Boolean Boolean

true 表示建立永久的 Cookie (跨瀏覽器工作階段儲存的 Cookie),否則為 falsetrue to create a persistent cookie (one that is saved across browser sessions); otherwise, false.

例外狀況

備註

方法會將表單驗證票證加入至 cookie 集合, 如果CookiesSupported為, false則為 URL。 SetAuthCookieThe 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. 使用表單驗證時, 您可以SetAuthCookie在想要驗證使用者, 但仍保有使用重新導向的導覽控制權時, 使用方法。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, String) SetAuthCookie(String, Boolean, String) SetAuthCookie(String, Boolean, String) SetAuthCookie(String, Boolean, String)

為所提供的使用者名稱建立驗證票證,並使用提供的 Cookie 路徑或使用 URL (若是使用 Cookieless 驗證),將該票證加入至回應的 Cookie 集合。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)

參數

userName
String String String String

已驗證使用者的名稱。The name of an authenticated user.

createPersistentCookie
Boolean Boolean Boolean Boolean

true 表示建立持久性 Cookie (跨瀏覽器工作階段儲存的 Cookie),否則為 falsetrue to create a durable cookie (one that is saved across browser sessions); otherwise, false.

strCookiePath
String String String String

表單驗證票證的 Cookie 路徑。The cookie path for the forms-authentication ticket.

例外狀況

備註

false如果SetAuthCookie 為,方法會將表單驗證票證加入cookie集合或URL。CookiesSupportedThe 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. 使用表單驗證時, 您可以SetAuthCookie在想要驗證使用者, 但仍保有使用重新導向的導覽控制權時, 使用方法。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.

另請參閱

適用於