Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. if(cookie && firstUsers[1]==='Pass') {
  2. alert("firstUsers is Pass");
  3. } else {
  4. alert("expired / not set");
  5. }
  6.  
  7. <script>
  8.  
  9. function firstUsers(){
  10. days=1;
  11. myDate = new Date();
  12. myDate.setTime(myDate.getTime()+(days*24*60*60*1000));
  13. document.cookie = 'firstUsers=Pass; expires=' + myDate.toGMTString();
  14. document.cookie = 'secondUsers=Pass; expires=' + myDate.toGMTString();
  15. }
  16.  
  17. var cookie = document.cookie.split(';')
  18. .map(function(x){ return x.trim().split('='); })
  19. .filter(function(x){ return x[0]==='firstUsers'; })
  20. .pop();
  21.  
  22. if(cookie && firstUsers[1]==='Pass') {
  23. alert("firstUsers is Pass");
  24. } else {
  25. alert("expired / not set");
  26. }
  27.  
  28. $('#set-btn').on('click', function(){
  29. // run code below
  30.  
  31. firstUsers();
  32. return false;
  33. });
  34.  
  35.  
  36. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement