delete() 공개 정적인 메소드

Deletes a named key from a single adapter (if a 'name' option is specified) or all session adapters.
public static delete ( string $key, array $options = [] ) : boolean
$key string The name of the session key to delete.
$options array Optional parameters that this method accepts: - `'name'` _string_: To force the delete to a specific adapter, specify the name of the configuration (i.e. `'default'`) here. - `'strategies'` _boolean_: Indicates whether or not a configuration's applied strategy classes should be enabled for this operation. Defaults to `true`.
리턴 boolean Returns `true` on successful delete, or `false` on failure.
예제 #1
0
 public function success()
 {
     $code = $this->request->query['code'];
     $access = Consumer::token('access', compact('code') + array('params' => array('redirect_uri' => Consumer::serviceConfig('success'))));
     Session::delete('oauth.access');
     Session::write('oauth.access', $access);
     $this->redirect('Facebook::feed');
 }
 public function testWriteReadDelete()
 {
     $key = 'test';
     $value = 'value';
     Session::write($key, $value, array('name' => 'test'));
     $result = Session::read($key, array('name' => 'test'));
     $this->assertEqual($value, $result);
     $this->assertTrue(Session::delete($key, array('name' => 'test')));
     $result = Session::read($key, array('name' => 'test'));
     $this->assertNull($result);
 }
예제 #3
0
 public function login()
 {
     Session::delete('oauth.request');
     Session::delete('oauth.access');
     $token = Consumer::token('request', array('params' => array('oauth_callback' => 'http://local.moodpik.com/tweet/success')));
     Session::write('oauth.request', $token);
     if (empty($token)) {
         $this->redirect('Tweet::authorize');
     }
     $this->redirect(Consumer::authenticate($token));
 }
예제 #4
0
 public function login($walletid = null, $msg = null)
 {
     Session::delete('default');
     if ($this->request->data) {
         if (stristr($_SERVER['HTTP_REFERER'], COMPANY_URL) === FALSE) {
             return $this->redirect('/wallet/login');
             exit;
         }
         $user = Users::find("first", array("conditions" => array("walletid" => $this->request->data['uuid'])));
         $details = Details::find('first', array('conditions' => array('walletid' => $this->request->data['uuid'])));
         if ($details['password']['send']['email'] === true) {
             //				print_r($this->request->data['signinpassword']);
             //print_r($deails['password']['send']['email']);exit;
             $signinpass = $this->request->data['signinpassword'];
             if ($signinpass != $details['signinCode']) {
                 return $this->redirect('wallet::login');
             } else {
                 $data = array('signinCodeused' => 'Yes');
                 Details::find('first', array('conditions' => array('walletid' => $this->request->data['uuid'])))->save($data);
             }
         }
         if (password_verify($this->request->data['password'], $user['password'])) {
             $uuid = new Uuid();
             $default = array("_id" => (string) $user['_id'], "code" => $user['code'], "email" => $user['email'], "phone" => $user['phone'], "password" => $this->request->data['password'], "walletid" => $user['walletid'], "xwalletid" => $uuid->hashme($user['walletid']), "xcode" => $user['xcode'], "xemail" => $user['xemail'], "xphone" => $user['xphone'], "greencoinAddress" => $user['greencoinAddress'][0], "ip" => $user['ip'], "created" => $user['created']);
             Session::write('default', $default);
             /////////////////////////////////////Check for signin alerts and alert user==================================
             $details = Details::find('first', array('conditions' => array('walletid' => $this->request->data['uuid'])));
             if ($details['alert']['email']['signin'] === true) {
                 $user = Users::find('first', array('conditions' => array('walletid' => $this->request->data['uuid'])));
                 $email = $user['email'];
                 // sending email to the users
                 /////////////////////////////////Email//////////////////////////////////////////////////
                 $emaildata = array('walletid' => $this->request->data['uuid'], 'email' => $email);
                 $function = new Functions();
                 $compact = array('data' => $emaildata);
                 $from = array(NOREPLY => "noreply@" . COMPANY_URL);
                 $email = $email;
                 $function->sendEmailTo($email, $compact, 'ex', 'sendEmailSignIn', "XGCWallet - Sign in", $from, '', '', '', null);
                 /////////////////////////////////Email//////////////////////////////////////////////////
             }
             /////////////////////////////////////Check for signin alerts and alert user==================================
             return $this->redirect('wallet::wallet');
         } else {
             return $this->redirect('wallet::login');
         }
     }
     return compact('walletid', 'msg');
 }
예제 #5
0
파일: CookieTest.php 프로젝트: Nys/lithium
 public function testStrategiesCookieAdapter()
 {
     $key = 'test_key';
     $value = 'test_value';
     Session::config(array('default' => array('adapter' => 'Cookie', 'strategies' => array('Hmac' => array('secret' => 'somesecretkey')))));
     $result = Session::write($key, $value);
     $this->assertTrue($result);
     $result = Session::read($key);
     $this->assertEqual($value, $result);
     $this->assertTrue(Session::delete($key));
     $result = Session::read($key);
     $this->assertNull($result);
     Session::write($key, $value);
     $result = Session::read($key);
     $this->assertEqual($value, $result);
     $this->assertTrue(Session::delete($key));
 }
예제 #6
0
 public function login()
 {
     $result = Auth::check($this->request->adapter, $this->request);
     $redirectUrl = $this->request->env('HTTP_REFERER') ?: '/';
     if ($result) {
         # Convert array to identity object
         if ($this->request->adapter === 'password') {
             $result = Identities::find($result['_id']);
         }
         $session_data = array();
         $new_session = uniqid();
         if (isset($result['session']['id'])) {
             $session_data['id'] = (array) $result['session']['id']->data();
         } else {
             $session_data['id'] = array();
         }
         // Remember users for two weeks
         $session_data['expires'] = time() + \app\util\Config::get('session_length', 7) * 24 * 60 * 60;
         array_push($session_data['id'], $new_session);
         setcookie('session.id', $new_session, $session_data['expires'], '/', $_SERVER['HTTP_HOST']);
         $result->save(array('session' => $session_data));
         Auth::set('any', $result);
     } else {
         $addendum = '';
         // Adapter-specific error messages
         if ($this->request->adapter == 'phpbb') {
             if (Session::read('non_linked_phpbb_login')) {
                 Session::delete('non_linked_phpbb_login');
                 $addendum = 'You are logged into the forums, but there is no leagues account associated with with your forum account.';
             } else {
                 $addendum = 'Please ensure that you are logged into the <a href="http://www.afdc.com/forum/">forums</a>.';
             }
         } else {
             Logger::debug("Failed login for " . $this->request->data['email'] . " with password " . $this->request->data["password"]);
         }
         $error_message = 'Your login was unsuccessful. ';
         if (isset($addendum) and !empty($addendum)) {
             $error_message .= "<br />{$addendum}`<br />";
         }
         $error_message .= 'If you\'re having trouble, checkout the <a href="/help/login">login instructions</a>.';
         $this->flashMessage($error_message, array('alertType' => 'error'));
     }
     return $this->redirect($redirectUrl);
 }
 public function delete()
 {
     Session::delete('user');
     return $this->redirect('/login');
 }
예제 #8
0
	public function tearDown() {
		Session::delete('FlashMessage');
	}
예제 #9
0
 /**
  * Provides a login page for users to login.
  *
  * @return type
  */
 public function login()
 {
     $user = Auth::check('li3b_user', $this->request);
     // 'triedAuthRedirect' so we don't end up in a redirect loop
     if (!Session::check('triedAuthRedirect', array('name' => 'cookie'))) {
         Session::write('triedAuthRedirect', 'false', array('name' => 'cookie', 'expires' => '+1 hour'));
     }
     // Facebook returns a session querystring... We don't want to show this to the user.
     // Just redirect back so it ditches the querystring. If the user is logged in, then
     // it will redirect like expected using the $url variable that has been set below.
     // Not sure why we need to do this, I'd figured $user would be set...And I think there's
     // a session just fine if there was no redirect and the user navigated away...
     // But for some reason it doesn't see $user and get to the redirect() part...
     if (isset($_GET['session'])) {
         $this->redirect(array('library' => 'li3b_users', 'controller' => 'users', 'action' => 'login'));
     }
     if ($user) {
         // Users will be redirected after logging in, but where to?
         $url = '/';
         // Default redirects for certain user roles
         switch ($user['role']) {
             case 'administrator':
             case 'content_editor':
                 $url = '/admin';
                 break;
             default:
                 $url = '/';
                 break;
         }
         // Second, look to see if a cookie was set. The could have ended up at the login page
         // because he/she tried to go to a restricted area. That URL was noted in a cookie.
         if (Session::check('beforeAuthURL', array('name' => 'cookie'))) {
             $url = Session::read('beforeAuthURL', array('name' => 'cookie'));
             // 'triedAuthRedirect' so we don't end up in a redirect loop
             $triedAuthRedirect = Session::read('triedAuthRedirect', array('name' => 'cookie'));
             if ($triedAuthRedirect == 'true') {
                 $url = '/';
                 Session::delete('triedAuthRedirect', array('name' => 'cookie'));
             } else {
                 Session::write('triedAuthRedirect', 'true', array('name' => 'cookie', 'expires' => '+1 hour'));
             }
             Session::delete('beforeAuthURL', array('name' => 'cookie'));
         }
         // Save last login IP and time
         $user_document = User::find('first', array('conditions' => array('_id' => $user['_id'])));
         if ($user_document) {
             $user_document->save(array('lastLoginIp' => $_SERVER['REMOTE_ADDR'], 'lastLoginTime' => new MongoDate()));
         }
         // only set a flash message if this is a login. it could be a redirect from somewhere else that has restricted access
         // $flash_message = FlashMessage::read('default');
         // if(!isset($flash_message['message']) || empty($flash_message['message'])) {
         FlashMessage::write('You\'ve successfully logged in.', 'default');
         // }
         $this->redirect($url);
     } else {
         if ($this->request->data) {
             FlashMessage::write('You entered an incorrect username and/or password.', 'default');
         }
     }
     $data = $this->request->data;
     return compact('data');
 }
예제 #10
0
 public function logout($provider = 'apontador')
 {
     if ($provider == 'foursquare') {
         Session::delete('foursquareToken');
         Session::delete('foursquareName');
         Session::delete('foursquarePhoto');
         Session::delete('foursquareEmail');
     } elseif ($provider == 'twitter') {
         Session::delete('twitterUserId');
         Session::delete('twitterScreenName');
         Session::delete('twitterToken');
         Session::delete('twitterTokenSecret');
     } elseif ($provider == 'facebook') {
         Session::delete('facebookToken');
         Session::delete('facebookId');
         Session::delete('facebookName');
     } elseif ($provider == 'orkut') {
         Session::delete('orkutUserId');
         Session::delete('orkutScreenName');
         Session::delete('orkutToken');
         Session::delete('orkutTokenSecret');
     } elseif ($provider == 'apontador') {
         Session::delete('apontadorToken');
         Session::delete('apontadorTokenSecret');
         Session::delete('apontadorId');
         Session::delete('apontadorName');
     }
     $this->redirect('/settings');
 }
예제 #11
0
 public function testStrategiesPhpAdapter()
 {
     Session::config(array('strategy' => array('adapter' => 'Php', 'strategies' => array('Hmac' => array('secret' => 'somesecretkey')))));
     $key = 'test';
     $value = 'value';
     Session::write($key, $value, array('name' => 'strategy'));
     $result = Session::read($key, array('name' => 'strategy'));
     $this->assertEqual($value, $result);
     $this->assertTrue(Session::delete($key, array('name' => 'strategy')));
     $result = Session::read($key, array('name' => 'strategy'));
     $this->assertNull($result);
     Session::write($key, $value, array('name' => 'strategy'));
     $result = Session::read($key, array('name' => 'strategy'));
     $this->assertEqual($value, $result);
     $cache = $_SESSION;
     $_SESSION['injectedkey'] = 'hax0r';
     $this->expectException('/Possible data tampering - HMAC signature does not match data./');
     $result = Session::read($key, array('name' => 'strategy'));
     $_SESSION = $cache;
 }
 public function tearDown()
 {
     Session::delete('default');
     FlashMessage::reset();
 }
예제 #13
0
 public function tearDown()
 {
     Session::delete('default');
 }
예제 #14
0
 public function testEncryptStrategyWithPhpAdapter()
 {
     $this->skipIf(PHP_SAPI === 'cli', 'No PHP session support in cli SAPI.');
     $this->skipIf(!extension_loaded('mcrypt'), 'The `mcrypt` extension is not loaded.');
     $config = array('name' => 'encryptInt');
     Session::config(array($config['name'] => array('adapter' => 'Php', 'strategies' => array('Encrypt' => array('secret' => 's3cr3t')))));
     Session::clear($config);
     $key = 'test';
     $value = 'value';
     $this->assertTrue(Session::write($key, $value, $config));
     $this->assertEqual($value, Session::read($key, $config));
     $this->assertTrue(Session::delete($key, $config));
     $this->assertNull(Session::read($key, $config));
     Session::clear($config);
     $this->assertTrue(Session::write('foo', 'bar', $config));
     $this->assertEqual('bar', Session::read('foo', $config));
     $this->assertTrue(Session::write('foo', 'bar1', $config));
     $this->assertEqual('bar1', Session::read('foo', $config));
     Session::clear($config);
     $this->assertTrue(Session::write($key, $value, $config));
     $this->assertEqual($value, Session::read($key, $config));
 }
예제 #15
0
 public function delete()
 {
     Auth::clear('member');
     Session::delete('default');
     return $this->redirect('/');
     exit;
 }
예제 #16
0
 public function delete()
 {
     Session::delete('default');
     return $this->redirect('/');
     exit;
 }
예제 #17
0
 /**
  * Tests deleting a session key from one or all adapters.
  *
  * @return void
  */
 public function testSessionKeyCheckAndDelete()
 {
     Session::config(array('temp' => array('adapter' => new Memory(), 'filters' => array()), 'persistent' => array('adapter' => new Memory(), 'filters' => array())));
     Session::write('key1', 'value', array('name' => 'persistent'));
     Session::write('key2', 'value', array('name' => 'temp'));
     $this->assertTrue(Session::check('key1'));
     $this->assertTrue(Session::check('key2'));
     $this->assertTrue(Session::check('key1', array('name' => 'persistent')));
     $this->assertFalse(Session::check('key1', array('name' => 'temp')));
     $this->assertFalse(Session::check('key2', array('name' => 'persistent')));
     $this->assertTrue(Session::check('key2', array('name' => 'temp')));
     Session::delete('key1');
     $this->assertFalse(Session::check('key1'));
     Session::write('key1', 'value', array('name' => 'persistent'));
     $this->assertTrue(Session::check('key1'));
     Session::delete('key1', array('name' => 'temp'));
     $this->assertTrue(Session::check('key1'));
     Session::delete('key1', array('name' => 'persistent'));
     $this->assertFalse(Session::check('key1'));
 }
예제 #18
0
    public function login() {
        $user = Auth::check('minerva_user', $this->request);
        if ($user) {
            // TODO: Put in a $redirectURL property so it can be controlled and option for the following redirect true/false for taking a user back to the page they first requested.
            // Also TODO: Make flash messages set in some sort of config, possibly even the model properties too
            $url = '/';
            if (Session::check('beforeAuthURL')) {
                $url = Session::read('beforeAuthURL');
                Session::delete('beforeAuthURL');				
            }
            // Save last login IP and time
            //$user_record = User::find('first', array('conditions' => array('_id' => new \MongoId($user['_id']))));
			$user_record = $this->getDocument(array(
				'action' => __METHOD__,
				'request' => $this->request,
				'find_type' => 'first',
				'conditions' => array('_id' => new \MongoId($user['_id']))
			));
			
            if($user_record) {
				$user_record->save(array('last_login_ip' => $_SERVER['REMOTE_ADDR'], 'last_login_time' => date('Y-m-d h:i:s')));
			}
            
            FlashMessage::set('You\'ve successfully logged in.');
            $this->redirect($url);
            //$this->redirect(array('controller' => 'pages', 'action' => 'index'));
        } else {
            if($this->request->data) {
                FlashMessage::set('You entered an incorrect username and/or password.', array('type' => 'error'));
            }
        }
        $data = $this->request->data;
        return compact('data');
    }
 public function testEncryptStrategyWithPhpAdapter()
 {
     $config = array('name' => 'encryptInt');
     Session::config(array($config['name'] => array('adapter' => 'Php', 'strategies' => array('Encrypt' => array('secret' => 's3cr3t')))));
     Session::clear($config);
     $key = 'test';
     $value = 'value';
     $this->assertTrue(Session::write($key, $value, $config));
     $this->assertEqual($value, Session::read($key, $config));
     $this->assertTrue(Session::delete($key, $config));
     $this->assertNull(Session::read($key, $config));
     Session::clear($config);
     $this->assertTrue(Session::write('foo', 'bar', $config));
     $this->assertEqual('bar', Session::read('foo', $config));
     $this->assertTrue(Session::write('foo', 'bar1', $config));
     $this->assertEqual('bar1', Session::read('foo', $config));
     Session::clear($config);
     $this->assertTrue(Session::write($key, $value, $config));
     $this->assertEqual($value, Session::read($key, $config));
 }
예제 #20
0
 public function logout()
 {
     Session::delete($this->_config['namespace']);
     return $this->redirect('Client::index', array('exit' => true));
 }