Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookie Collection 1

Status
Not open for further replies.

developer155

Programmer
Jan 21, 2004
512
US
Hi I have a function that sets a cookie after a user action.
Basically what happens is a use views properties. I set a cookie whe a property is viewd (tracknum and propnum are property numbers). As you see, when user looks at next properrty, cookie will be overwritten with next property's numbers. I need to keep up to 10 property cookies. How can I do this? I will also need to go throught all the property cookies and check if a certain one exists. Here is what I have for setting a single cookie:
public void SetLeadCookie()
{
HttpCookie cookLead = new HttpCookie("lead");
cookLead["tracknum"] = myQsp.GetValByKey("tracknum");
cookLead["propnum"] = myQsp.GetValByKey("propnum");
Response.Cookies.Add(cookLead);

}

thanks for any help!
 
You could either change the name of the cookie so that each property has it's own individual cookie (then you simply have to check for the existence of each cookie). Alternatively, you can use the same cookie and change the key names that you use and maybe append the property number onto the end of each one. That way, you'll have to read the cookie and check for the existence of the relevant property number.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks,
but how do I go through values or keys for a cookie:

foreach ( ??? val in cookLead.Values)

Also, how many keys can one cookie have

 
Just loop through the Values e.g.
Code:
        For Each s As String In ck.Values
            Response.Write(s)
        Next


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Oh, and I'm not sure how many keys/values a cookie can have but I think they are limited to around 4k.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top