Permalänk
Medlem

ASP - Räkna variabler i Cookie?

Jag snickrar lite på ett litet röstningsscript i ASP.
Har en fundering nu, går det att kontrollera hur många variabler som lagts till en cookie? Vet att man kontrollera om cookien överhuvudtaget innehåller variabler, men jag skulle mer specifikt vilja veta hur många som lagts till.

Går det?

Visa signatur
Permalänk
Medlem

"You can also iterate through the values of all the cookies in a collection, or all the keys in a cookie. However, if you try to iterate through the values for a cookie that does not have keys, nothing will be returned. To avoid this, you can first use the .HasKeys syntax to check whether a cookie has any keys, as shown in the following example."

<% If Not cookie.HasKeys Then 'Set the value of the cookie. Response.Cookies(cookie) = "" Else 'Set the value for each key in the cookie collection. For Each key in Response.Cookies(cookie) Response.Cookies(cookie)(key) = "" Next %>

http://msdn.microsoft.com/library/en-us/iissdk/iis/ref_vbom_r...

Borde väl bara att göra om den där koden så att du skriver ut alla värden för varje key.

Permalänk
Medlem

Tack! Ska titta på det.

EDIT:

For Each key in Response.Cookies("playlistcookie")
ctr = ctr + 1
Next

Klockrent. Tack än en gång.

Visa signatur