Welcome Guest, Not a member yet? Register   Sign In
Session store
#1

[eluser]babai[/eluser]
I want to store the session in Array.

Now session are storing by default into CI_Session Object. Actual I have print ( print_r($this->session); ) the session and getting the result. See the example

CI_Session Object
(
[now] => 1216134421
[encryption] =>
[use_database] => 1
[session_table] => ci_sessions
[sess_length] => 1800
[sess_cookie] => ci_session
[userdata] => Array
(

[username] => sudip
[user_id] => 1
[full_name] => Sudip Samanta
[power_user] => y
[s_home_dir] => .
[twg_permissions] => 7
[upload_settings] => 15
[mywebgallerie_login] => ok
[s_user] => admin
[admin_lang] => en
)
}

But I want to store some session data into an Array. Means I want to split the previous example into 2 parts. See the example

1.
CI_Session Object
(
[now] => 1216134421
[encryption] =>
[use_database] => 1
[session_table] => ci_sessions
[sess_length] => 1800
[sess_cookie] => ci_session
[userdata] => Array
(

[username] => sudip
[user_id] => 1
[full_name] => Sudip Samanta
[power_user] => y
)
}

2.
Array
(
[s_home_dir] => .
[twg_permissions] => 7
[upload_settings] => 15
[mywebgallerie_login] => ok
[s_user] => admin
[admin_lang] => en
}

Is it possible? If it is possible so how to store into the session. Now I am using
'$this->session->set_userdata('admin_lang', 'en')'.
#2

[eluser]hvalente13[/eluser]
[quote author="babai" date="1216154563"]I want to store the session in Array.

Now session are storing by default into CI_Session Object. Actual I have print ( print_r($this->session); ) the session and getting the result. See the example
[/quote]

Quote:2.
Array
(
[s_home_dir] => .
[twg_permissions] => 7
[upload_settings] => 15
[mywebgallerie_login] => ok
[s_user] => admin
[admin_lang] => en
}

Is it possible? If it is possible so how to store into the session. Now I am using
'$this->session->set_userdata('admin_lang', 'en')'.


You can get the session data by using:

Code:
$my_array = array(
    's_home_dir' => $this->session->userdata('s_home_dir'),
    'twg_permissions' => $this->session->userdata('twg_permissions'),
    'upload_settings' => $this->session->userdata('upload_settings'),
    'mywebgallerie_login' => $this->session->userdata('mywebgallerie_login'),
    's_user' => $this->session->userdata('s_user'),
    'admin_lang' => $this->session->userdata('admin_lang'),
);

And to store data into CI Session object it's how you have been doing:

Code:
$this->session->set_userdata('admin_lang', 'en')

Good luck
#3

[eluser]babai[/eluser]
No, I want to store the data into session out side of CI Session object. If I print print_r($_SESSION); that will be display

Array
(
[s_home_dir] => .
[twg_permissions] => 7
[upload_settings] => 15
[mywebgallerie_login] => ok
[s_user] => admin
[admin_lang] => en
}

Not display the

CI Session object
(
[s_home_dir] => .
[twg_permissions] => 7
[upload_settings] => 15
[mywebgallerie_login] => ok
[s_user] => admin
[admin_lang] => en
}

I mean when I will set a data into session it will not store into CI Session object. It will be store into global session array.




Theme © iAndrew 2016 - Forum software by © MyBB