Set a cookie in JavaScript ...

how do i set a cookie with javascript that has more than one value I know how to set them in VBScript ie:

(set a cookie called C_Name that will store first & last name and age)...

Response.Cookies("C_Name")("FName")= "xxx"
Response.Cookies("C_Name")("LName")= "xxx"
Response.Cookies("C_Name")("Age")= "xxx"


Then to retrieve the info stored in the cookie:

first = Request.Cookies("C_Name")("FName")
last = Request.Cookies("C_Name")("LName")
u_age = Request.Cookies("C_Name")("Age")


Thanks
r_fritzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

r_fritzAuthor Commented:
need a quick response. will up the points to 150 if i get a answer by 5:00 p.m. today (1/27/00)
0
cheekycjCommented:
===========================================
<SCRIPT LANGUAGE="JavaScript">
<!--
//Standard function, from InternetWorld
function GetCookie (name) {  
  var arg = name + "=";  
  var alen = arg.length;  
  var clen = document.cookie.length;  
  var i = 0;  

  while (i < clen) {    
    var j = i + alen;    
    if (document.cookie.substring(i, j) == arg)      
      return getCookieVal (j);    

    i = document.cookie.indexOf(" ", i) + 1;    
    if (i == 0) break;    
  }  
  return null;
}

//Standard function, from InternetWorld
function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

//Standard function, from InternetWorld
function SetCookie (name, value) {  
  var argv = SetCookie.arguments;  
  var argc = SetCookie.arguments.length;  
  var expires = (argc > 2) ? argv[2] : null;  
  var path = (argc > 3) ? argv[3] : null;  
  var domain = (argc > 4) ? argv[4] : null;  
  var secure = (argc > 5) ? argv[5] : false;  
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +  
    ((domain == null) ? "" : ("; domain=" + domain)) +    
    ((secure == true) ? "; secure" : "");
}

//Standard function, from InternetWorld
function DeleteCookie (name) {  
  var exp = new Date();  
  exp.setTime (exp.getTime() - 1);  
  // This cookie is history  
  var cval = GetCookie (name);  
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
==================================

These are your standard JS cookie functions.

CJ
0
cheekycjCommented:
Did this help r_fritz?

CJ
0
cheekycjCommented:
I am posting as an answer because I believe I did answer the Q.

CJ
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.