风火家人开发记要

技术总结精华贴

Tag: CodeIgniter

CMS, 原创

codeigniter(CI)刷新页面新增空session数据解决方案codeigniter(CI) refurbish page new session data added resolvent

使用codeigniter(CI)开发网站,使用自带session时会出现写seesion失败,但数据库中添加空session,每次刷新页面都会新增。 这个问题产生是由于手册给到的帮助信息中创建session表的时候有个字段的长度不够造成的,只要修改这个长度就可以了, 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 DEFAULT ” NOT NULL, PRIMARY KEY (session_id) ); 将user_agent varchar(50) NOT NULL,的字段长度改到255吧,50太少了,查看网站上,他至少也是60多个字符。use codeigniter(CI)to develop website, session writed failed,and session table of database be added empty session,every time you refurbish page. this is because you use the example of handbook about session,you need to change something. 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 DEFAULT ” NOT NULL, PRIMARY KEY (session_id) ); change 50 to 255 in this string : user_agent varchar(50) NOT NULL.Hope it can help you. (1350)

查看全文