store and retrieve cookie values in C#
<p>I have a slot machine application which displays a flash file using c#. Any user would come to the site and play the game. But I would need to limit that a max of 3 times per day, meaning he could play the game only 3 times and if he goes to play the fourth time, then he would get a message indicating he could play the next day. Since there is no user login on this site, i have decided to store cookie values. It would be counter that would increment each time he gets into the site. Then, on each page_load event, retrieve the cookie value and if its 3, then display the No Play Message.</p>

<p>First i would retrieve the value of cookie on page load event.</p>

<pre><code>string _counter = response.Cookies["slotmachinecookie"]["counter"];
    if (!IsPostBack)
    {
    if (_counter) = 3
       //displayMessage
       return;
    else
    {
       HttpCookie cookie = new HttpCookie("slotmachinecookie");
       if (string.IsNullOrEmpty(_counter))
         cookie.Values.Add("1", "counter");
       else if (_counter == "1")
         cookie.Values.Add("2", "counter")
       else if (_counter == "2")
         cookie.Values.Add("3", "counter");
    }
}
</code></pre>

<p>Will this work? I guess i could try it but just want to make sure if there is a better way other than cookies to do this? Thanks in advance.</p>
