Advertisement
Skorpius

Session and cookies HttpOnly & Secure

Feb 19th, 2023 (edited)
603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. Tutorial - https://youtu.be/TrWda1AwyAA
  2.  
  3.     //Secure sessions - http only - will only work on https connection
  4.     function sessionStart($lifetime, $path, $domain, $secure, $httpOnly){
  5.         session_set_cookie_params($lifetime, $path, $domain, $secure, $httpOnly);
  6.        
  7.         session_start();
  8.     }
  9.  
  10. //Cookies
  11. $domain = 'localhost';
  12. $myTime = time()+(10 * 365 * 24 * 60 *60);
  13. setcookie ("member_login", $email,$myTime, '/', $domain, true, true);
  14.  
  15. //To double check these are HttpOnly and Secure, when in your browser, press f12, goto the application tab, look under cookies and sessions. You should see a tick in both HttpOnly and Secure column
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement