SharePoint - Can anyone help out in creating a cookie on java script

Asked By Mano on 13-Sep-10 11:13 AM

Hi,

   I am trying to create cookie on java script that is embedded with HTML Document. My Criteria is totally there are three objects and one of that would be selected as a first by users those who visiting that site clicking on one object among three that is mostly like by the user. So in this i want to find which one of the object is mostly clicked by the user so here first i want to set a cookie and then i don't have any idea can one suggest me a idea what i could do for this ? ?
Venkat K replied to Mano on 13-Sep-10 11:55 AM
I don't think creating a cookie in javascript will help you out in this scenario. What i understand is you need to get one of the three options which the users has selected more. Once the user is selected one of the object you nees to store the value selected by the user in the database or some where in the form of XML along with the user id and finally you can generate a report or fetch the max number of users who selected which object etc....

anyways  Here is how to set a cookie in javascript:
function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

Thanks
Mano replied to Venkat K on 13-Sep-10 12:33 PM
 First of all thanks for replied me what you understood is correct But this coding which you have written will fully carry out my scenario or else do i need something else to meet my requirements other than you have shown is there any else could you suggest me how could i do ?? 
Because as far as my knowledge i know that first of all we should create a cookie and i don't know much about it now only learning but you have said that this would not help me in my scenario if so what else method i can use to fulfill my scenario 
if you see this please reply me ? 
 
thanks