Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.62 KB  |  hits: 33  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Custom 'secure' php and MySQL user login session system
  2. $salt = to64(getRandomBytes(16));
  3.  
  4. if (CRYPT_BLOWFISH == 1)
  5.     $securePassword = crypt($password, '$2a$10$'.$salt);
  6.        
  7. session.use_trans_sid = 0
  8. session.use_only_cookies = 1
  9. session.hash_function = sha512
  10. session.hash_bits_per_character = 5
  11.        
  12. session_set_cookie_params("86400", "/");
  13. session_name("auth");
  14. session_start();
  15.  
  16. $_SESSION['userId'] = $row[0];
  17. $_SESSION['created'] = time();
  18.        
  19. if($_SESSION['created'] + 30 * 60 < time())
  20. {
  21.     session_regenerate_id ();
  22.     $_SESSION['created'] = time();
  23. }
  24.        
  25. session_set_cookie_params('86400', '/', '', true, true);