Advertisement
Guest User

Untitled

a guest
Nov 9th, 2016
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <script>
  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.toUTCString();
  6. document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
  7. }
  8. </script>
  9. <script>
  10. function getCookie(cname) {
  11. var name = cname + "=";
  12. var ca = document.cookie.split(';');
  13. for(var i = 0; i < ca.length; i++) {
  14. var c = ca[i];
  15. while (c.charAt(0) == ' ') {
  16. c = c.substring(1);
  17. }
  18. if (c.indexOf(name) == 0) {
  19. return c.substring(name.length, c.length);
  20. }
  21. }
  22. return "";
  23. }
  24. </script>
  25. <script>
  26. function checkCookie() {
  27. var id = getCookie("schoolid");
  28. if (id != "") {
  29. alert("Welcome again ");
  30. } else {
  31. alert("user");
  32. }
  33. }
  34. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement