Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 ASP.NET Javascript , +
How to read and write data to cookies by use javascript.thank you.
Posted 29-Aug-12 2:40am
pucx1.2K
Edited 29-Aug-12 2:43am
__TR__28.9K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Don't you know about google[^]? Your subject itself is giving About 4,510,000 results (0.28 seconds). Google is your friend. Try using that first. If any problem comes then you can ask for the solution. We all are here to guide you, help you.
 

All the best.
--Amit
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Following links might help you:
JavaScript Cookies[^]
JavaScript and Cookies[^]
 
All the best.
--Rajesh
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

hi, try it like this:
function setCookie(name,value)
{
    var Days = 30;
    var exp = new Date(); 
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
 
function getCookie(Name) {
    var search = "[" + Name + "]="
          if (document.cookie.length > 0) { // if there are any cookies
                    offset = document.cookie.indexOf(search) 
                    if (offset != -1) { // if cookie exists 
                              offset += search.length 
                              // set index of beginning of value
                              end = document.cookie.indexOf(";", offset) 
                              // set index of end of cookie value
                              if (end == -1) 
                                        end = document.cookie.length
                              return unescape(document.cookie.substring(offset, end))
                    } 
          }
}//:$

 
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 290
1 Jochen Arndt 165
2 DamithSL 125
3 PIEBALDconsult 110
4 Garth J Lancaster 90
0 OriginalGriff 5,790
1 DamithSL 4,601
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,195


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 29 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100