can i append a perticuler cookies from multiple cookies

Discussion in 'JavaScript' started by kim.ray, Jul 31, 2008.

  1. #1
    hi dear,
    i am try to store multiple cookies. just like this

    document.cookie = "cookies1=" + a;
    document.cookie = "cookies2=" + b;


    but now i want append a particular cookies let say "cookies1" how can i do this
    i need ur favor,plz.

    thanx
     
    kim.ray, Jul 31, 2008 IP
  2. selling vcc

    selling vcc Peon

    Messages:
    361
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try this function

         
    <script type="text/javascript">
    function getCookie(name)
          {
            var cookies = document.cookie + ';';
            nameStart = cookies.indexOf(name+'=');
            if(nameStart == -1) 
              return false;
            valueStart = nameStart + name.length +1;
            valueEnd = cookies.indexOf(';',valueStart) -1;
            valueLength = valueEnd + 1 - valueStart;
            value = cookies.substr(valueStart, valueLength);
            value = unescape(value);
            return value;
          }
    </script>
    
    HTML:
     
    selling vcc, Aug 1, 2008 IP