Export (0) Print
Expand All

HttpCookie.Values Property

Gets a collection of key-and-value value pairs that are contained within a single cookie object.

[Visual Basic]
Public ReadOnly Property Values As NameValueCollection
[C#]
public NameValueCollection Values {get;}
[C++]
public: __property NameValueCollection* get_Values();
[JScript]
public function get Values() : NameValueCollection;

Property Value

A collection of cookie values.

Example

The following example creates a new cookie and adds several values to it. For an example of how to extract multiple values from one cookie, see HasKeys.

[Visual Basic] 
Dim MyCookie As HttpCookie = New HttpCookie("Cookie1")
 MyCookie.Values("Val1") = "1"
 MyCookie.Values("Val2") = "2"
 MyCookie.Values("Val3") = "3"
 Response.Cookies.Add(MyCookie)
    

[C#] 
HttpCookie MyCookie = new HttpCookie("Cookie1");
 MyCookie.Values["Val1"] = "1";
 MyCookie.Values["Val2"] = "2";
 MyCookie.Values["Val3"] = "3";
 Response.Cookies.Add(MyCookie);
    

[C++] 
HttpCookie* MyCookie = new HttpCookie(S"Cookie1");
 MyCookie->Values->Item[S"Val1"] = S"1";
 MyCookie->Values->Item[S"Val2"] = S"2";
 MyCookie->Values->Item[S"Val3"] = S"3";
 Response->Cookies->Add(MyCookie);
    

[JScript] 
var myCookie : HttpCookie = new HttpCookie("Cookie1")
myCookie.Values["Val1"] = "1"
myCookie.Values["Val2"] = "2"
myCookie.Values["Val3"] = "3"
Response.Cookies.Add(myCookie)
   

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HttpCookie Class | HttpCookie Members | System.Web Namespace

Show:
© 2015 Microsoft