• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help, Session problems.

some session problems about obsession.
config.php copy:
//codeigniter session.
$config['sess_cookie_name']        = 'vszone.net';
$config['sess_expiration']        = 0;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']        = 'sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']     = 7200;
// [OB] additional config items:
$config['sess_storage']             = 'database';
$config['sess_database']            = 'default';
$config['sess_timeout']             = 0;
$config['sess_destroy_on_timeout']  = FALSE;
$config['sess_update_interval']     = 300;
$config['sess_gc_probability']      = 10;
$config['sess_http_only']           = FALSE;
$config['sess_send_hdr']            = '';

//cookie configuration.
$config['cookie_prefix']    = "";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/";

got problems:

1、Why each page has own record in sessions table?
even i refresh the same page once it was added one record again?

2、Why session has saved ,but others page can't get it?
in a function has used :
$sess = array('uid'=>1,'name'=>'test');
and in the view page used;
$this->session->userdata('uid');//it's empty!

3、the cookie vszone.net value not only contains session_id, but all other values.

For problem # 2, I had the similar thing happen for me. When I tried to add data to the session array by passing an array and then redirecting, none of them were stored. I am not sure but I think it has something to do with the redirect but I found that if I assigned one variable at a time that it then worked.

Instead of:
$sess = array(’uid’=>1,’name’=>’test’);

Possibly try:
$this->session->set_userdata(’uid’, 1);
$this->session->set_userdata(’name’, ’test’);

I don't know if this is the best way but it seemed to work for me. I had multiple variables so I looped through them with a foreach loop.

$sess = array(’uid’=>1,’name’=>’test’);
foreach($sess as $key => $value) {
    $this->session->set_userdata($key, $value);

Finally i found that reason of my problem was:

$config['sess_cookie_name'] = 'vszone.net';

it contains the dot symboal!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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