<?php
class Store_memberModel extends Model{
        public function checklogin(){
			if(!cookie('feimao_store_username')) {
				header("Location:". gurl('','account','login') ."");
			}else{
				$username = cookie('feimao_store_username');
				$u_data = M('users')->where("username='$username'")->find();
				$salt = $u_data['salt'];
				$token = md5(md5($username).md5($salt));
				$data = M('users_token')->where("username = '$username' and token='$token'")->find();
				if(!$data) {
					header("Location:". gurl('','account','login') ."");
				}elseif($data['addtime']+C('logint') >= time()) {
					cookie('feimao_store_username',null);
					M('users_token')->where("username = '$username' and token='$token'")->delete();
					header("Location:". gurl('','account','login') ."");
				}else{
					//echo 1;
					//header("Location:". gurl('','index','') ."");
				}
			}
        }
		public function logout(){
			$username = cookie('feimao_store_username');
			cookie('feimao_store_username',null);
			M('users_token')->where("username = '$username'")->delete();
			header("Location:". gurl('','account','login') ."");
		}
    }
?>