FormsAuthentication.GetAuthCookie Method (String, Boolean, String)

Creates an authentication cookie for a given user name. This does not set the cookie as part of the outgoing response.

Namespace: System.Web.Security
Assembly: System.Web (in system.web.dll)

public static HttpCookie GetAuthCookie (
	string userName,
	bool createPersistentCookie,
	string strCookiePath
public static HttpCookie GetAuthCookie (
	String userName, 
	boolean createPersistentCookie, 
	String strCookiePath
public static function GetAuthCookie (
	userName : String, 
	createPersistentCookie : boolean, 
	strCookiePath : String
) : HttpCookie
Not applicable.



The name of the authenticated user.


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


The Path of the authentication cookie.

Return Value

An HttpCookie that contains encrypted forms-authentication ticket information.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0