Welcome Guest, Not a member yet? Register   Sign In
Lost session
#61

[eluser]baudday[/eluser]
[quote author="Derek Allard" date="1205368324"]Sessions are not readable until the next page load. If you moved to another controller, you should be able to see it.[/quote]

Man I had almost this EXACT same problem and this is the key! Judging by all the threads on this, I don't think many people know this, but thank you so much. This helped me a lot!
#62

[eluser]Unknown[/eluser]
I had the same problem with userdata session in IE.

I have a library (Auth.php) where I checked the login and set a couple of userdata. After the redirect/refresh in the loginmodel my session in IE was lost in the next pages.

My solution was:
in the Auth.php I closed the session with session_write_close();

Example:
Code:
$this->session->set_userdata('mysession', 'myvalue');
session_write_close();

Maybe it will help other people to solve the same problem.
#63

[eluser]baudday[/eluser]
So I discovered my real problem was that my array that I was trying to pass was too large. When I made it smaller all the data was retained. Not sure if there's a size restriction on session variables, but this solved my problem.
#64

[eluser]WanWizard[/eluser]
For cookie based sessions, the limit is the maximum size of the cookie, 4Kb. For database sessions, the size is only limited by the size of the user_data field.

In both cases, a serialized array is stored, so you need to calculate a couple of bytes extra (p.e. 10) for the type and length indicators.

session_write_close() is a PHP function, which doesn't have any meaning in CI (unless you use native sessions).
#65

[eluser]wwwrun[/eluser]
Generally I'm not a thread-gravedigger but I just stumbled upon this issue too while fiddling with UTF-8 chars in the session (cart) and got it fixed, jamesf was on the right way:

[quote author="jamesf" date="1272484444"]I was having the same issue and I believe it was caused by certain UTF-8 characters in the session. As a quick fix I used the base64_encode/base64_decode functions in the _serialize/_unserialize methods like this
[/quote]

It's definitely an UTF-8 encoding issue, but I didn't want to have base64 encoded Strings in my DB. You can also fix the Session.php class by adding utf8 en- and decoding like this (CI 2.0.1):

Code:
function _unserialize($data)
{
  $data = @unserialize(utf8_decode(strip_slashes($data)));
  [...]
}

and

Code:
function _serialize($data)
{
  [...]    
  return utf8_encode(serialize($data));
}

Works like a charm and keeps your DB Sessions readable/debuggable.

Cheers
#66

[eluser]WanWizard[/eluser]
I've always used UTF-8 in my CI projects, and I have yet to encounter any issue with it, including sessions.

You have to make sure though that the database you use is also configured to store and use UTF-8. If not, you'll get funny conversion problems which might be the case here.
#67

[eluser]Unknown[/eluser]
please help me !!

My Session Data Not Set

codeigniter version: 2.0.0

in local no problem but in linux server PHP Version 5.2.17
my session data not set in IE and opera and safari Browser but Firefox is ok

in window server session set in IE and Firefox but linux not set

It is a bug?
I do not know

the classic session of php Good work
sample
session_start();
$_SESSION['username']="sara"

please help me!!!


this is sample code

sessiontest.php
location:
controller/sessiontest.php
Code:
class Sessiontest extends CI_Controller{
    function index(){
       $this->load->library('session');
       //$this->load->library('Native_session');
       $newdata = array(
                   'username'  => 'johndoe',
                   'email'     => '[email protected]',
                   'logged_in' => TRUE
               );

        $this->session->set_userdata($newdata);
        
        
            
    }
}


sessiontest2.php
location:
controller/sessiontest2.php

Code:
class sessiontest2 extends CI_Controller{
    function index(){
       $this->load->library('session');
       //$this->load->library('Native_session');        
       echo $this->session->userdata('username');
       echo $this->session->userdata('session_id');
      
    }
}
#68

[eluser]William Rufino[/eluser]
Well I'm losing session after redirects! :/
#69

[eluser]sheepland[/eluser]
*duplicate* *please delete, admin*
#70

[eluser]sheepland[/eluser]
From what I read in this thread, I managed to solve the session problem: in file config/config.php just rename the sess_cookie_name to something without underscore, ie. from 'ci_session' to 'cisession'. That worked for me. Cheers.




Theme © iAndrew 2016 - Forum software by © MyBB