CodeIgniter Forums
Session Class -> sess_destroy not removing session - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Session Class -> sess_destroy not removing session (/showthread.php?tid=55417)

Pages: 1 2


Session Class -> sess_destroy not removing session - El Forum - 06-12-2013

[eluser]CroNiX[/eluser]
Code:
$is_logged_in = $this->session->userdata('is_logged_in');

            //if its not set and if not true, redirect to public pages
            if(!isset($is_logged_in) || $is_logged_in !== TRUE)
            {
                redirect('web_public/index');
                die();
            }
You might want to reread the session user guide on what the class will return if a session variable does NOT exist. Your code is checking to see if the variable is set, which it always will be because the function returns boolean FALSE if it doesn't exist.


Session Class -> sess_destroy not removing session - El Forum - 06-12-2013

[eluser]CroNiX[/eluser]
[quote author="Bart v B" date="1371055551"]
Code:
if(!isset($is_logged_in) || $is_logged_in !== TRUE)
            {
                redirect('web_public/index');
                die();
            }
Why in the world are you letting your script go dead?
die() stops everything. An exit() should be better here.[/quote]

In PHP, exit() === die(). Check the PHP userguide. They reference each other.

http://php.net/manual/en/function.die.php
Quote:This language construct is equivalent to exit().
Quote:die — Equivalent to exit

http://www.php.net/manual/en/function.exit.php
Quote:Note:

This language construct is equivalent to die().