Welcome Guest, Not a member yet? Register   Sign In
using sessions from one function to another
#7

[eluser]gtech[/eluser]
Code:
<?php
class Temp extends Controller {

function Temp()
{
parent::Controller();
$this->load->library('session');
}
function index()
{
$this->session->set_userdata('testkey','testvalue');
echo 'set session';
}
function getsess() {
echo $this->session->userdata('testkey');
}
}
?&gt; <-CHECK THERE IS NO SPACE HERE as cutting and pasting will produce a space!
I will try to explain

when you use the session it is set by sending header information to the browser.. when you display content this also sends header information to the browser.

So if you echo content or load a view before you set the session information you will get the headers already sent error message you are seeing..

what will also cause headers to be sent is any characters outside the php tags.. as your webserver will not send information to the browser that is inside the php tags.. but characters outside the tags will be sent to the browser, causing headers to be sent also.

hope this helps to explain your error. your error message is at line 18 which is suspiciously the end of the file!


Messages In This Thread
using sessions from one function to another - by El Forum - 05-21-2008, 01:02 AM
using sessions from one function to another - by El Forum - 05-21-2008, 05:55 AM
using sessions from one function to another - by El Forum - 05-21-2008, 08:07 AM
using sessions from one function to another - by El Forum - 05-21-2008, 08:45 AM
using sessions from one function to another - by El Forum - 05-21-2008, 09:50 AM
using sessions from one function to another - by El Forum - 05-21-2008, 10:06 AM
using sessions from one function to another - by El Forum - 05-21-2008, 10:15 AM
using sessions from one function to another - by El Forum - 05-21-2008, 10:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB