• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lost session

#11
[eluser]Coyoterj[/eluser]
Hi CI's friends,

I like CodeIgniter and participate in the brazilian forum.
I have a problem and before turning to the forum, I reduce my code to facilitate

In controller:

Code:
function update() {
    $this->segment = $this->uri->segment(4);
    print_r($this->segment);
    if ( !($this->session->userdata('produpId')) ) $this->session->set_userdata('produpId', $this->segment);
    var_dump($this->session->userdata('produpId'));

The result:
5
string(1) "5"

Then, a view is called with one only form and return for function update. The result
Code:
var_dump($this->session->userdata('produpId'));

bool(false).

I changed CI Session with PHP $_SESSION, and no problem... But I want to use CI Session.. ;-)

[To be] a bug [or not to be] a bug ?? :lol:

Thanks and good lucky for us!

#12
[eluser]Derek Allard[/eluser]
Sessions are not readable until the next page load. If you moved to another controller, you should be able to see it.

#13
[eluser]Coyoterj[/eluser]
[quote author="Coyoterj" date="1205368225"]Hi CI's friends,

In controller:

Code:
function update() {
    $this->segment = $this->uri->segment(4);
    print_r($this->segment);
    if ( !($this->session->userdata('produpId')) ) $this->session->set_userdata('produpId', $this->segment);
    var_dump($this->session->userdata('produpId'));

The result:
5
string(1) "5"

Then, a view is called with one only form and return for function update. The result
Code:
var_dump($this->session->userdata('produpId'));

bool(false).

[/quote]

Hi Derek ! Thanks for the helping.

Just in case, the function update is in a controller named prod.php, this function calls a view container.php with a form inside it.
In this form i have used a form_open('prod/update') and when it return to prod/update i lost the session.
Is this correct ?

Best regards,

#14
[eluser]tomodian[/eluser]
Maybe this article helps you.
http://ellislab.com/forums/viewthread/74354/

#15
[eluser]kopeah[/eluser]
Does anyone have any answer to this session issue? I also have a hard time reading anything from session. I even try by enabling database for storing session variables but still failed. It did populate ci_session table like it should just have hard time retrieving any data from it. I tested with both firefox and IE .. both have the same problem, so its not browser related.

I didn't have any problem with session in the past, could it be something with the new version?

#16
[eluser]Derek Allard[/eluser]
Hi Kopeah, welcome to CodeIgniter.

Are you setting your session on one page and trying to read on another, or are you trying to do it all in one page?

#17
[eluser]kopeah[/eluser]
Hi Derek,

I got the session set on one page and another page trying to read it.

#18
[eluser]Derek Allard[/eluser]
ok, let's take a look at some code. Can you put some here for us to look at?

How is the session library loaded?

#19
[eluser]kopeah[/eluser]
Well this is what I have to test session.

First page (login.php)

Code:
class Login extends Controller {

    function Login()
    {
        parent::Controller();
        
        $this->load->library('session');
        
        $this->load->database();
        
        $this->load->helper('url');
        $this->load->helper('form');

    }

        function usercheck()
        {
                // Checking username,password,acl
                // Omit all the database queries
                $sessionData = array(
                                     'accessLevel' => $acl,
                                     'user' => $username
                                     );
                                                                        
                $this->session->set_userdata($sessionData);
                            
        redirect('test/main');    
        }
}

Second page (test.php)

Code:
class Test extends Controller {

    function Test()
    {
        parent::Controller();
        
        $this->load->library('session');
        
        $this->load->database();
        
        $this->load->helper('url');
        $this->load->helper('form');

    }
    
    function main()
    {
        $level = $this->session->userdata('accessLevel');
        $user = $this->session->userdata('user');
        
        echo "Access Level: $level <br />";
        echo "Username: $user <br />";
    }
    
    
}

#20
[eluser]Derek Allard[/eluser]
Hi Mike.

Looking I don't see anything off hand. Where does $acl come from? Does it behave this way in all browsers? Have you tried another server by chance?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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