FormsAuthentication.GetAuthCookie 方法

定义

为给定的用户名创建身份验证 Cookie。

重载

GetAuthCookie(String, Boolean)

为给定的用户名创建身份验证 Cookie。 这不会将 Cookie 设置为传出响应的一部分,因此应用程序对如何发出该 Cookie 有更多的控制权限。

GetAuthCookie(String, Boolean, String)

为给定的用户名创建身份验证 Cookie。 这不会将 Cookie 设置为传出响应的一部分。

GetAuthCookie(String, Boolean)

为给定的用户名创建身份验证 Cookie。 这不会将 Cookie 设置为传出响应的一部分,因此应用程序对如何发出该 Cookie 有更多的控制权限。

public:
 static System::Web::HttpCookie ^ GetAuthCookie(System::String ^ userName, bool createPersistentCookie);
public static System.Web.HttpCookie GetAuthCookie (string userName, bool createPersistentCookie);
static member GetAuthCookie : string * bool -> System.Web.HttpCookie
Public Shared Function GetAuthCookie (userName As String, createPersistentCookie As Boolean) As HttpCookie

参数

userName
String

已验证身份的用户的名称。

createPersistentCookie
Boolean

若要创建持久 Cookie(跨浏览器会话保存的 Cookie),则为 true;否则为 false

返回

一个 HttpCookie,其中包含加密的 Forms 身份验证票证信息。 使用 FormsCookiePath 属性的默认值。

注解

Cookie 的路径由 FormsCookiePath 属性确定。

另请参阅

适用于

GetAuthCookie(String, Boolean, String)

为给定的用户名创建身份验证 Cookie。 这不会将 Cookie 设置为传出响应的一部分。

public:
 static System::Web::HttpCookie ^ GetAuthCookie(System::String ^ userName, bool createPersistentCookie, System::String ^ strCookiePath);
public static System.Web.HttpCookie GetAuthCookie (string userName, bool createPersistentCookie, string strCookiePath);
static member GetAuthCookie : string * bool * string -> System.Web.HttpCookie
Public Shared Function GetAuthCookie (userName As String, createPersistentCookie As Boolean, strCookiePath As String) As HttpCookie

参数

userName
String

已验证身份的用户的名称。

createPersistentCookie
Boolean

若要创建持久 Cookie(跨浏览器会话保存的 Cookie),则为 true;否则为 false

strCookiePath
String

身份验证 Cookie 的 Path

返回

一个 HttpCookie,其中包含加密的 Forms 身份验证票证信息。

另请参阅

适用于