views:

115

answers:

1

On a site I'm coding, there's a Partners page that contains, amongst other things, a phone number for that business to view.

My boss wants this phone number to be hidden then, upon being clicked, appear (I'll fade it in with jQuery) and then log the click. This will allow him to keep track of the amount of people that have shown interest in that business.

Although I've never done any AJAX stuff with jQuery before, I can't imagine that part will be hard (feel free to give some examples though :> ). The problem I'm having is keeping the numbers visible after they've been logged. If the user reloads the page, they don't want to have to re-click and re-log that click. The number should already be visible. So this is where the cookie comes in.

I'll log what numbers have been clicked in the user's cookie then perform a cookie check before loading the page. Allowing me to show the already viewed numbers and keep the unviewed numbers hidden until clicked.

If I have, lets say, 20 numbers however, I don't want twenty different cookies to keep track of. So I figured storing all numbers in one cookie's array would work. I've never worked with cookies outside of PHP, though. So I have no idea how to do this.

How does I do?

A: 

You can store it in one cookie string with some kind of separator. For example: "1;2;3" Then split it to array by ";" character.

x2
Isn't the ';' considered a deliminator for cookies? Anyway, I see your point. That might be my way to go. Thanks for the help
spirax