Guest User

Untitled

a guest
Feb 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. function cookie_set($key, $value)
  2. {
  3.     setcookie(
  4.         $key,
  5.         base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($config['salt']), $value, MCRYPT_MODE_CBC, md5(md5($config['salt'])))),
  6.         time()+$config['expire']
  7.     );
  8. }
  9.  
  10. function cookie_get($key)
  11. {
  12.     return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($config['salt']), base64_decode($_COOKIE[$key]), MCRYPT_MODE_CBC, md5(md5($config['salt']))), "\0");
  13. }
  14.  
  15. $config = array(
  16.     // Database
  17.     'db_host' => 'localhost',
  18.     'db_user' => 'root',
  19.     'db_pass' => '',
  20.     'db_name' => '',
  21.  
  22.     // Cookies
  23.     'salt' => 'xxx',
  24.     'expire' => 1209600, // 14 days
  25. );
Add Comment
Please, Sign In to add comment