Guest User

Untitled

a guest
Sep 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. PHP Create and delete cookies using query strings
  2. <a href="index.php?showDesktop=true">Show Desktop</a>
  3.  
  4. <a href="index.php?showMobile=true">Show Mobile</a>
  5.  
  6. if($_GET['showDesktop']) {
  7. $_COOKIE('showDesktop', 'yes');
  8. $_COOKIE('showMobile', null);
  9. }
  10. else if($_GET['showMobile']) {
  11. $_COOKIE('showDesktop', null);
  12. $_COOKIE('showMobile', 'yes');
  13. }
  14.  
  15. setcookie('showDesktop', 'yes', time()+86400*365);
  16. setcookie('showMobile', false);
  17.  
  18. setcookie('displayMode', 'desktop', time()+86400*365);
  19.  
  20. if($_GET['showDesktop'] == 'true') {
  21. setcookie('showDesktop', true);
  22. setcookie('showMobile', false);
  23. }
  24. else if($_GET['showMobile'] == 'true') {
  25. setcookie('showDesktop', false);
  26. setcookie('showMobile', true);
  27. }
  28.  
  29. if($_GET['showDesktop']) {
  30. $_COOKIE('showDesktop', 'yes');
  31. }
  32. else if($_GET['showMobile']) {
  33. $_COOKIE('showDesktop', 'no');
  34. }
  35.  
  36. setcookie ("showDesktop", "", time() - 3600);
Add Comment
Please, Sign In to add comment