asp.net.ph

HttpCookie.Name Property

System.Web Namespace   HttpCookie Class


Sets or retrieves the name of a cookie.

[ VB ]
Public Property Name As String

[ C# ]
public string Name {get; set;}

[ C++ ]
public: __property String* get_Name ( );
public: __property void set_Name ( String* );

[ JScript ]
public function get Name ( ) : String;
public function set Name ( String );

Property Value

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

Example

The following 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.

[ VB ]
Dim loop1 As Integer
Dim myCookie As HttpCookie
Dim myCookieCollection As HttpCookieCollection 
 
 myCookieCollection = Request.Cookies

For loop1 = 0 TO myCookieCollection.Count - 1
    myCookie = myCookieCollection ( loop1 ) 
   If myCookie.Name = "UserName" Then
       ' ... do whatever here ...
   End If
Next loop1


[ C# ]
int loop1;
HttpCookie myCookie;
HttpCookieCollection myCookieCollection;

 myCookieCollection = Request.Cookies;

For ( loop1 = 0; loop1 < myCookieCollection.Count; loop1++ ) {
    myCookie = myCookieCollection [ loop1 ];
  If ( myCookie.Name == "UserName" ) {
       // ... do whatever here ...
   }
}
See Also

HttpCookie Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph