Guest User

Untitled

a guest
Jun 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. this is dashboard.php
  2.  
  3. <?php
  4. class Dashboard extends CI_Controller{
  5.  
  6. function index()
  7. {
  8. $done=$this->session->flashdata('userEmail');
  9.  
  10. if(!$done)
  11. {
  12. echo "not login";
  13. $this->load->view('main/login_form');
  14. }
  15. else
  16. {
  17. echo "welcome to dashboard" ;
  18. $this->session->keep_flashdata('userEmail');
  19.  
  20. }
  21.  
  22. echo "<br/>" ;
  23.  
  24.  
  25. }
  26.  
  27.  
  28. }
  29.  
  30.  
  31. ?>
  32.  
  33. and this login.php code::
  34.  
  35. public function login()
  36. {
  37.  
  38.  
  39. if(isset($_COOKIE['wathba']))
  40. {
  41. $this->session->set_flashdata('userEmail', $this->session->userdata('userEmail'));
  42. redirect('dashboard');
  43.  
  44. }
  45.  
  46.  
  47. $this->form_validation->set_rules('userEmail','email','trim|required|valid_email|callback_check_login');
  48. $this->form_validation->set_rules('userPassword','password','trim|required|md5');
  49.  
  50.  
  51. if($this->form_validation->run()==TRUE)
  52. {
  53.  
  54.  
  55.  
  56. if($this->user_model->Login(array('userEmail'=>$this->input->post('userEmail'),'userPassword'=>$this->input->post('userPassword'))))
  57. { redirect('main/login');
  58.  
  59.  
  60. }
  61.  
  62.  
  63.  
  64. else
  65. {
  66.  
  67.  
  68. $this->session->set_flashdata('userEmail', $this->input->post('userEmail'));
  69. $check_box=$this->input->post('remember');
  70. echo $check_box ;
  71. if ($check_box=="remember me")
  72. {
  73. echo " checked" ;
  74. $value=array('userpassword'=>$this->input->post('userPassword'),'userEmail'=>$this->input->post('userEmail'));
  75. $value=serialize($value);
  76. $cookie=array(
  77. 'name'=>'wathba',
  78. 'value'=>$value ,
  79. 'expire'=>'2410000', //in seconds
  80. );
  81. $this->input->set_cookie($cookie);
  82.  
  83. }
  84.  
  85. the problem is that i have cookies stord in my computer , and when login is redirect me automatically to
  86. dashboard.php and give me the result of
  87.  
  88. echo "not login";
  89. $this->load->view('main/login_form'
  90.  
  91. that is false , it must echo "dashboard"
  92.  
  93. how can i use instead of this sentence $this->session->set_flashdata('userEmail', $this->session->userdata('userEmail'));
  94.  
  95. (how i can use data from cookies ?)
Add Comment
Please, Sign In to add comment