Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. // Set cookies
  2. function setCookie(cname,cvalue,exdays) {
  3. var d = new Date();
  4. d.setTime(d.getTime()+(exdays*24*60*60*1000));
  5. var expires = "expires="+d.toGMTString();
  6. document.cookie = cname + "=" + cvalue + "; " + expires;
  7. }
  8. function getCookie(cname) {
  9. var name = cname + "=";
  10. var ca = document.cookie.split(';');
  11. for(var i=0; i<ca.length; i++) {
  12. var c = ca[i].trim();
  13. if (c.indexOf(name)==0) return c.substring(name.length,c.length);
  14. }
  15. return "";
  16. }
  17.  
  18.  
  19. function START() {
  20. setCookie("ie",'user1',30);
  21. //var urlp =document.getElementById('download_pdf');
  22. //window.location.href= urlp;
  23. }
  24.  
  25. function READ(user) {
  26. var user=getCookie("ie");
  27. if (user!="") {
  28. alert("Welcome again " + user);
  29. } else {
  30. START();
  31. }
  32. }
  33.  
  34. READ('stackoverflow');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement