working with CI sessions |
[eluser]sasori[/eluser]
hi this is my first time to try sessions of CI and im in trouble LOL here's my controller code Code: public function login() model Code: public function login($username,$password) view Code: <?php when i try to log-in with a correct data, I'm just getting the "you aren't logged in"
[eluser]guidorossi[/eluser]
2 things... 1- are you loading the session library? 2- I think Code: isset($_SESSION['username'] Code: isset($this->session->userdata('username')) Code: echo "you are logged in as .". $_SESSION['username']; Code: echo "you are logged in as .". $this->session->userdata('username');
[eluser]sasori[/eluser]
ok i tried what you said, now am getting this error Code: Fatal error: Can't use method return value in write context in C:\xampp\htdocs\myapp\application\views\member_view.php on line 4 where line 4 is the Code: if(isset($this->session->userdata('username'))){ (btw the session class is autoloaded from the config)
[eluser]guidorossi[/eluser]
Sorry about that, it should be Code: <?php but I suggest you to take a look at this video tutorial from nettuts to get some good practices because I think your code have some security issues like setting the cookie data before calling the login model.... http://net.tutsplus.com/videos/screencas...y-6-login/
[eluser]sasori[/eluser]
lol , too late, I was already downloading it since my last reply from this thread. but anyway. thanks for the help. |
Welcome Guest, Not a member yet? Register Sign In |