Click here to Skip to main content
15,907,493 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have a Online Q/A web application,i want to set count down for each candidate,i want to use cookie for each candidate that store count down value,and expiry after three mints, i have wrote cookie using following code,
i want a jquery code to read this code and display a counter,and after finishing time durtion,redirect user to Result.aspx page, the reason of using cookie because simple jquery count down reset on page refresh.

What I have tried:

C#
HttpCookie candcookie = new HttpCookie("candcookie");
               Response.Cookies["candcookie"]["RollNumber"] = cnic;
               Response.Cookies["candcookie"]["time"] = DateTime.Now.ToString();
               candcookie.Expires = DateTime.Now.AddMinutes(3);
               Response.Cookies.Add(candcookie);
Posted
Updated 24-Mar-16 3:15am
Comments
Sinisa Hajnal 24-Mar-16 3:07am    
And...what have you tried with javascript? You're showing c# code which has nothing to do with javascript. It is easily found by googling, both for jQuery (cookie plugin) and javascript document.cookies collection. What is the problem?

You don't want to use jQuery to read a cookie because it does not have a native way of accessing cookies. Seems like it should though.

However, just use native JavaScript. w3Schools has a good walkthrough on how to work with cookies in JavaScript. See JavaScript Cookies[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900