• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with session pff help me

#1
[eluser]MrAmine[/eluser]
why my code its not working
Code:
class Login extends CI_Controller{
    function index(){
      $session = $this->session->userdata('username');      
      if(isset($session)){
          redirect('homepage');
        }else{
           redirect('loginpage');
          }
     }
}

#2
[eluser]allaerd[/eluser]
did you load the session library?

#3
[eluser]Nur Cholikul Anwar[/eluser]
First: please check what session library has loaded?
Second: try this code
Code:
class Login extends CI_Controller{
public function index(){
   $session = $this->session->userdata('username');      
   !empty($session) ? redirect('homepage') : redirect('loginpage');
}

I hope no typos

#4
[eluser]WanWizard[/eluser]
Look carefully at this bit of code
Code:
$session = $this->session->userdata('username');      
if(isset($session)){
    ....

and tell me in what situation will $session not be set?

#5
[eluser]InsiteFX[/eluser]
LOL!

#6
[eluser]Nur Cholikul Anwar[/eluser]
[quote author="InsiteFX" date="1303413891"]LOL![/quote]

Please don't Big Grin


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.