Why session become blank on several pages in codeigniter?
I was to irritate that session did not work or became blank on sevral pages during work on website.
i tried too many short ways but they all are works for some time or some place finally i got
a permanent way to store a session in mvc codeigniter.
First of all go in application/config/config.php
open this file and change this content
$config['sess_use_database'] = FALSE;
TO
$config['sess_use_database'] = TRUE;
and
$config['sess_table_name'] = 'ci_sessions';
// sess_table_name should be "ci_sessions"
when You change this after that copy and paste this sql query in database
CREATE TABLE IF NOT EXISTS `ci_sessions` (
`session_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
`ip_address` varchar(16) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
`user_agent` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`last_activity` int(10) unsigned NOT NULL DEFAULT '0',
`user_data` text COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`session_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
and clear the cache and cookie of browser hope this will work well.
Happy coading
i tried too many short ways but they all are works for some time or some place finally i got
a permanent way to store a session in mvc codeigniter.
First of all go in application/config/config.php
open this file and change this content
$config['sess_use_database'] = FALSE;
TO
$config['sess_use_database'] = TRUE;
and
$config['sess_table_name'] = 'ci_sessions';
// sess_table_name should be "ci_sessions"
when You change this after that copy and paste this sql query in database
CREATE TABLE IF NOT EXISTS `ci_sessions` (
`session_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
`ip_address` varchar(16) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
`user_agent` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`last_activity` int(10) unsigned NOT NULL DEFAULT '0',
`user_data` text COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`session_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
and clear the cache and cookie of browser hope this will work well.
Happy coading
Thanks for your post.
ReplyDelete