Facing problem with set_cookie |
[eluser]Hiraman Patil[/eluser]
Hello all I am new with code igniter + PostgreSQL please help on following code. I am trying to set cookie here. but not success yet. This is my code if($this->input->post('rememberme') == 'yes') { $this->load->helper('cookie'); $cookie = array('login_email' => $this->input->post('email'), 'login_password' => $this->input->post('password')); set_cookie($cookie); } please give suggestion on this and also how can I access the cookie variable in controller. thanks
[eluser]Craig A Rodway[/eluser]
The cookie is not being set because you are not using the correct syntax. Please check the Cookie Helper documentation and adjust your code. Hint: You will need to call set_cookie() twice if you want to set two cookies. I'd also like to point out that storing a user's password in a cookie is insecure and considered bad practice.
[eluser]flaky[/eluser]
you don't have to use set_cookie use the codeigniter session which by default saves the information in the cookie Code: $this->load->library('session');
[eluser]paulon[/eluser]
[quote author="flaky" date="1261684028"]you don't have to use set_cookie use the codeigniter session which by default saves the information in the cookie Code: $this->load->library('session'); what if i dont want to use $this->session->set_userdata($newdata); because i dont want to save the information in the cookie. i want to avoid some user who login then close the browser then reopen the site the same session will load, is their other alternative?
[eluser]flaky[/eluser]
check this solution, it's what you are looking for http://ellislab.com/forums/viewthread/70036/
[eluser]Hiraman Patil[/eluser]
Hi flaky Suppose I am using your solution. then If I logged out from site then how can I fetch data from session ? I want to store data in cookie to show automaticcally on login page when user logged out.
[eluser]flaky[/eluser]
if you are using CI session then, the moment the user clicks logout you could save that in the session example Code: public function logout(){ and when the user wants to login you just read the session |
Welcome Guest, Not a member yet? Register Sign In |