Skip to content

Instantly share code, notes, and snippets.

@no13bus
Created March 6, 2014 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save no13bus/9389531 to your computer and use it in GitHub Desktop.
Save no13bus/9389531 to your computer and use it in GitHub Desktop.
class CommonAction extends Action
{
public function _initialize()
{
if(isset($_COOKIE['auto']) && !isset($_SESSION['uid'])){
$auto=explode('|',$_COOKIE['auto']);
$where=array('uid'=>$auto[0],'username'=>$auto[1]);
$user=M('user')->where($where)->find();
if ($user) {
session('uid',$user['id']);
session('username',$user['username']);
session('email',$user['email']);
$this->user_info = $user;
$this->loginbool = 1;
}
}else if(isset($_SESSION['uid'])){
$user=M('user')->where(array('uid' => $_SESSION['uid']))->find();
$this->user_info = $user;
$this->loginbool = 1;
}else{
$this->loginbool = 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment