HttpCookieCollection.Get Method (Int32)

Returns the HttpCookie item with the specified index from the cookie collection.

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

public:
HttpCookie^ Get (
	int index
)
public HttpCookie Get (
	int index
)
public function Get (
	index : int
) : HttpCookie
Not applicable.

Parameters

index

The index of the cookie to return from the collection.

Return Value

The HttpCookie specified by index.

The following example returns each cookie from the cookie collection, checks whether it is named "LastVisit", and, if "LastVisit" is found, updates its value to the current date and time.

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

for (loop1 = 0; loop1 < myCookieCollection.get_Count(); loop1++) {
    myCookie = myCookieCollection.Get(loop1);
    if (myCookie.get_Value().equals("LastVisit")) {
        myCookie.set_Value(DateTime.get_Now().ToString());
        myCookieCollection.Set(myCookie);
    }
}

var myCookie : HttpCookie
var myCookieCollection : HttpCookieCollection = Request.Cookies

for(var i=0; i < myCookieCollection.Count; i++){
  myCookie = myCookieCollection.Get(i)
  if(myCookie.Name == "LastVisit"){
      myCookie.Value = DateTime.Now.ToString()
      myCookieCollection.Set(myCookie)
  }
}
  

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: