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

首先模拟会员登录和退出,有两个重要文件,一个是include下的memberlogin.class.php和include/helpers下的cache.helper.php文件。

原理为:memberlogin.class.php通过使用缓存助手 helper('cache'),然后/member/config.php 文件引入memberlogin.class.php文件实现模拟登录和退出。

模拟会员登录代码
 
引入/member/config.php
 
$cfg_ml->DelCache($cfg_ml->M_ID);//清除会员登录缓存
$cfg_ml->PutLoginInfo($mid);//让某用户登录
 
模拟会员退出代码
 
引入/member/config.php
 
$cfg_ml->DelCache($cfg_ml->M_ID);//清除会员登录缓存
$cfg_ml->ExitCookie();//退出当前登录用户