ThinkPHP - 登录模块,核心代码
2016-07-22 17:54
549 查看
/** * 登录成功 * @return [type] [description] */ public function checkLogin($data) { $user = M($this->tableName); $map['name'] = array('eq', $data['name']); $map['pwd'] = array('eq', $data['pwd']); $findres = $user->where($map)->find(); if ($findres) { // 如验证正确,则修改相应信息 $id = $findres['id']; $updatedata['lasttime'] = time(); $updatedata['lastip'] = get_client_ip(); $whe['id'] = array('eq', $id); $updateres = $user->where($whe)->data($updatedata)->save(); if ($updateres) { // 修改相应信息成功,写入session session('id', $findres['id']); session('name', $findres['name']); session('lasttime', $findres['lasttime']); session('lastip', $findres['lastip']); if (session('id') && session('name') && session('lasttime') && session('lastip')) { // session 存储成功,返回true。 return true; } else { return false; } } else { return false; } } else { return false; } }
相关文章推荐
- PHP Reflection API是PHP5才有的新功能
- FTP 的搭建过程和遇到的问题
- php命名空间namespace自动载入
- YIIweb.php中urlManager的配置
- 【php】mysql事务commit自动提交
- PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0
- Zend-MVC intro
- 49.View the Exhibit to examine the output of the DBA_OUTSTANDING_ALERTS view.
- PHP查看目录下的所有文件
- php iframe 父级页面跳转 登陆页面跳转
- php 编写一个简单的模板引擎
- php加密函数使用
- PHP 变量作用域
- php的clone 浅拷贝
- php的一些总结
- sublime text ftp插件使用
- 关于WinNT和WinCE中使用NTP协议
- TP框架基础(一)
- PHPSESSID的cookie//session_start()
- 让PHP7达到最高性能的几个Tips