How to handle when Session become blank on some pages.



In this Tutorial, we are Showing solution to codeigniter developer. Some time we get irritate due to session break or session get blank on some pages during making live project on Codeigniter or website.
Developers use many short cut and uses sessions those stay only for some times. Here I am showing you how to keep session for a long time on all pages. We are showing permanent solution for storing a session in MVC module of codeigniter.

Open the file and change some content into it.
First you have to follow the path application/config/config.php
$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" 

After changing this syntax just copy and paste the SQL Query into Database.
CREATE TABLE IF NOT EXISTS `ci_sessions` (
  `session_id` varchar(60) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
  `ip_address` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
  `user_agent` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
  `last_activity` int(20) 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 the just clear all the cookies and clear cache of model.


You Might Also Read : -

 

0 comments :

Post a Comment

 
# Top