文章来源:http://www.imtr.cn/html/n251.html
首先模拟会员登录和退出,有两个重要文件,分别为include下的memberlogin.class.php和include/helpers下的cache.helper.php文件。
原理为memberlogin.class.php通过使用缓存助手 helper('cache'),然后/member/config.php 文件引入memberlogin.class.php文件实现模拟登录和退出。
模拟会员登录代码
require_once(dirname(__FILE__)."/config.php"); $cfg_ml = new MemberLogin(60*60*24*365);//设置有效登录时间365天 $cfg_ml->PutLoginInfo($mid);//让某用户登录
模拟会员退出代码
require_once(dirname(__FILE__)."/config.php"); $cfg_ml->DelCache($cfg_ml->M_ID);//清除会员登录缓存 $cfg_ml->ExitCookie();//退出当前登录用户
模拟代码要预先引入/member/config.php才能生效哦
require_once(dirname(__FILE__)."/config.php");//模拟文件在member文件夹时,直接写入这一句
原文地址:http://www.imtr.cn/html/n251.html