Welcome Guest, Not a member yet? Register   Sign In
Help, Session problems.
#1

[eluser]benyu[/eluser]
some session problems about obsession.
config.php copy:
Code:
//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');
$this->session->set_userdata($sess);
redirect("/",'refresh');
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.
#2

[eluser]Unknown[/eluser]
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:
Code:
$sess = array(’uid’=>1,’name’=>’test’);
$this->session->set_userdata($sess);
redirect("/",’refresh’);

Possibly try:
Code:
$this->session->set_userdata(’uid’, 1);
$this->session->set_userdata(’name’, ’test’);
redirect("/",’refresh’);

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.

Code:
$sess = array(’uid’=>1,’name’=>’test’);
foreach($sess as $key => $value) {
    $this->session->set_userdata($key, $value);
}
redirect("/",’refresh’);
#3

[eluser]benyu[/eluser]
Oh!
Finally i found that reason of my problem was:

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

it contains the dot symboal!




Theme © iAndrew 2016 - Forum software by © MyBB