Welcome Guest, Not a member yet? Register   Sign In
its a bug? session library
#1

[eluser]alebenson[/eluser]
hi there!
i was doing something with sessions and i got this error
Message: Cannot modify header information - headers already sent by...

i look it up in the forum and everyone said that is the space before ?> or an echo... so i made test to discard those things

1_first

Code:
class Test extends Controller {
    
function index()
{
    $this->load->library('session');
    $check = $this->session->userdata('session_id');
    if ($check == FALSE)
    {
        echo 'FALSE FALSE FALSE';
    }
    else
    {
        echo 'OK! OK! OK!';
    }
}
}

result OK! OK! OK!


2_second

Code:
class Test extends Controller {
    
function index()
{
    $this->load->library('session');
    $this->session->sess_destroy(); //// NEW LINE HERE
    $check = $this->session->userdata('session_id');
    if ($check == FALSE)
    {
        echo 'FALSE FALSE FALSE';
    }
    else
    {
        echo 'OK! OK! OK!';
    }
}
}

result OK! OK! OK!

same results
well i dont get the error... but i dont understand why i get the same result after a kill the session
#2

[eluser]rafsoaken[/eluser]
I had a look into the source of library/Session.php of the svn version (CI 1.60), and it seems that $this->session->userdata is just not reset when you execute $this->session->sess_destroy().

In the controller you'd have to do either something like:
Code:
$this->session->sess_destroy();
$this->session->userdata=array();
or create a new session - the old one gets deleted along with its data:
Code:
$this->session->sess_create();
In the 2nd case of course, you'd have again a session_id.
#3

[eluser]Pascal Kriete[/eluser]
sess_destroy() simply moves the cookie timestamp to the past, so that it will be deleted when the page is reloaded. So it does get cleared, but no right away.

If you only have that one variable you could use unset_userdata().
#4

[eluser]alebenson[/eluser]
ok is working now.

but to test a set_userdata i have to do another function that test it
if i do it in the same scrip i get the error header message

thanks




Theme © iAndrew 2016 - Forum software by © MyBB