Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeIgniter sess_destroy does not delete user_data session?
    text
    copied!<p>I am creating test case for my CodeIgniter app. However I just found something that I thought should not be happen :</p> <p>in login.php controller : </p> <pre><code>public function logout() { $this-&gt;session-&gt;sess_destroy(); redirect('/'); } </code></pre> <p>So I just created a test to just make sure that session is really destroyed :</p> <pre><code>public function test_logout() { $this-&gt;CI = set_controller('login'); // make sure that all session is destroyed $this-&gt;CI-&gt;session-&gt;set_userdata('test_session', 'some_value'); $this-&gt;CI-&gt;logout(); // userdata 'test_session' should be removed! $this-&gt;assertTrue(($this-&gt;CI-&gt;session-&gt;userdata('test_session')==null || $this-&gt;CI-&gt;session-&gt;userdata('test_session')=='')); } </code></pre> <p>However I find that upon running the test case, my test case fails! Upon debug on the last line of test case, I found that the userdata is still exist with value = 'some_value'. I thought that sess_destroy should also delete all the set user data, as per what they described in their <a href="http://ellislab.com/codeigniter%20/user-guide/libraries/sessions.html" rel="nofollow">website documentation</a>:</p> <blockquote> <p>This function should be the last one called, and even flash variables will no longer be available. If you only want some items destroyed and not all, use unset_userdata().</p> </blockquote> <p>I am using Kenji's CIUnit for unit testing. Is this the correct behaviour or is there something that I missed?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload