CodeIgniter Forums
custom session data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: custom session data (/showthread.php?tid=20515)



custom session data - El Forum - 07-13-2009

[eluser]jorx[LINUX][/eluser]
hi guyz!!! I'm saving session data to mysql db---- is it possible to add custom data to the session array?!!!!!


custom session data - El Forum - 07-13-2009

[eluser]Thorpe Obazee[/eluser]
Did you try $this->session->set_userdata('key', 'value');?


custom session data - El Forum - 07-13-2009

[eluser]jorx[LINUX][/eluser]
yes...


i had use this sample query from the user guide

Code:
CREATE TABLE IF NOT EXISTS  `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) DEFAULT '0' NOT NULL,
user_agent varchar(50) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id)
);

do i have to add an additional table(s) for the custom data?


custom session data - El Forum - 07-13-2009

[eluser]riko0na[/eluser]
bargainph

"Most programmers are lazy. If you're like me, you're lazy too." from pinoytech.org

hehe..lol


custom session data - El Forum - 07-13-2009

[eluser]Thorpe Obazee[/eluser]
[quote author="jorx[LINUX]" date="1247493965"]yes...


i had use this sample query from the user guide

Code:
CREATE TABLE IF NOT EXISTS  `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) DEFAULT '0' NOT NULL,
user_agent varchar(50) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id)
);

do i have to add an additional table(s) for the custom data?[/quote]

That table is mostly what you'll need. No additional tables.


custom session data - El Forum - 07-13-2009

[eluser]bigtony[/eluser]
The custom sesssion variables are put into the 'user_data' text field of the ci_sessions table.


custom session data - El Forum - 07-13-2009

[eluser]jorx[LINUX][/eluser]
thankz guyz!!!!!!