function recover_session($token=''){
		//$r = Env::getRequest();
		$key = Env::getConfig("jwt")->get('key');

		$expiration = Env::getConfig("jwt")->get('token_expiration');
		$cookie_key=   Env::getConfig("jwt")->get('cookie_key');

		if(empty($key) || empty($expiration) || empty($cookie_key)){
			throw new Exception("critical security failure. Please configure module",00);
		}
		//retrieve user token // priority order -> cookie-> headers
		$result = false;
		if(empty($token)){
			$token = (isset($_COOKIE[$cookie_key]))? $_COOKIE[$cookie_key] : Env::getRequest()->getToken();
		}
	//	var_dump($_COOKIE);

		try{


			//var_dump($token);

			$decoded = array();
			if(!empty($token)){
				$decoded = JWT::decode($token, $key, array('HS256'));

				if($decoded){
					//authenticated
					$result = true;
					$this->setToken($token);
				//	var_dump($token);
					if(Env::getConfig("jwt")->get('auto_renew')){
						$this->create_session((array)$decoded->data);
					}

					//$key = $this->getEntity()->onePKName();
				//	$this->load_user($decoded->data->$key);

				}
			}
		}
		catch(\Firebase\JWT\ExpiredException $e){

			$this->setError("Expired token, please log in again",101);
			return false;
		}
		catch( \Exception $e){

			$this->setError("Invalid token ".var_export($e,true),102);
			return false;
		}finally{
			if ($result) {
			//	$this->logout();

				$this->setDefaultDatas((array)$decoded->data);
				return true;
			}
		}
		return false;
	}