Advertisement
wolfgang1983

Untitled

Jul 22nd, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <?php
  2.  
  3. defined('BASEPATH') OR exit('No direct script access allowed');
  4.  
  5. class Welcome extends CI_Controller {
  6.  
  7. public function index()
  8. {
  9. $this->load->library('encryption');
  10. $this->load->helper('url');
  11.  
  12. $user_id = '1';
  13.  
  14. $identifier = crypt($user_id,'$6$5,j$2.$');
  15.  
  16. $token = "$2y$10$".bin2hex(openssl_random_pseudo_bytes(22));
  17.  
  18. $timeout = time() + 60 * 60 * 24 * 7;
  19.  
  20. $remember = $this->input->post('remember');
  21.  
  22. if (isset($remember)) {
  23.  
  24. $data = array(
  25. 'user_id' => $user_id,
  26. 'token' => $token,
  27. );
  28.  
  29. //$this->session->set_userdata($data);
  30.  
  31. /*
  32. If the user checks the remember me checkbox then insert
  33. the identifier and token to database
  34. */
  35.  
  36. $cookie = array(
  37. 'name' => 'remember',
  38. 'value' => "$identifier:$token",
  39. 'expire' => $timeout,
  40. 'domain' => '.localhost',
  41. 'prefix' => '',
  42. 'secure' => FALSE
  43. 'httponly' => TRUE,
  44. );
  45.  
  46. $this->input->set_cookie($cookie);
  47.  
  48. }
  49.  
  50. $this->load->view('welcome_message');
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement