HttpCookie.Name Property

Gets or sets the name of a cookie.

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

public:
property String^ Name {
	String^ get ();
	void set (String^ value);
}
/** @property */
public String get_Name ()

/** @property */
public void set_Name (String value)

public function get Name () : String

public function set Name (value : String)

Not applicable.

Property Value

The default value is a null reference (Nothing in Visual Basic) unless the constructor specifies otherwise.

The following code example receives a cookie collection from the client in the Cookie header and loops through the collection looking for a cookie with the specific name.

No code example is currently available or this language may not be supported.
int loop1;
HttpCookie myCookie;
HttpCookieCollection myCookieCollection;

myCookieCollection = get_Request().get_Cookies();
for (loop1 = 0; loop1 < myCookieCollection.get_Count(); loop1++) {
    myCookie = myCookieCollection.get_Item(loop1);
    if (myCookie.get_Name().equals("UserName")) {
        //...
    }
}

var myCookie : HttpCookie
var myCookieCollection : HttpCookieCollection 

myCookieCollection = Request.Cookies

for(var i = 0; i < myCookieCollection.Count; i++){
   myCookie = myCookieCollection[i]
   if(myCookie.Name == "UserName"){
      //...
   }
}
   

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

Community Additions

ADD
Show: