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.

備註

SetAuthCookie方法將表單驗證票證的 cookie 集合或 URL 若CookiesSupportedfalseThe 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.

例外狀況

備註

SetAuthCookie方法會將表單驗證票證的其中一個 cookie 集合,或 URL 若CookiesSupportedfalseThe 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.

例外狀況

備註

SetAuthCookie方法將表單驗證票證的 cookie 集合或 URL 若CookiesSupportedfalseThe 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.

另請參閱

適用於