DedeCms织梦模拟会员登录和退出的代码

2020-04-09 新手入门 浏览 手机预览
文章来源:http://www.imtr.cn/html/n251.html

首先模拟会员登录和退出,有两个重要文件,分别为include下的memberlogin.class.phpinclude/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
  • 如果你的问题还没有解决,可以点击页面右侧的“ ”,站长收到问题后会尽快回复解决方案到你的邮箱。
  • 创造始于问题,有了问题才会思考,有了思考,才有解决问题的方法,才有找到独立思路的可能。 —— 陶行知