remove() static public method

Removes a value from the session by key
static public remove ( mixed $key ) : array
$key mixed The key to remove by
return array The session array without the value
Exemplo n.º 1
0
 public function message()
 {
     if ($message = s::get('message') and is_array($message)) {
         $text = a::get($message, 'text');
         $type = a::get($message, 'type', 'notification');
         $element = new Brick('div');
         $element->addClass('message');
         if ($type == 'error') {
             $element->addClass('message-is-alert');
         } else {
             $element->addClass('message-is-notice');
         }
         $element->append(function () use($text) {
             $content = new Brick('span');
             $content->addClass('message-content');
             $content->text($text);
             return $content;
         });
         $element->append(function () {
             $toggle = new Brick('a');
             $toggle->attr('href', url::current());
             $toggle->addClass('message-toggle');
             $toggle->html('<i>&times;</i>');
             return $toggle;
         });
         s::remove('message');
         return $element;
     }
 }
Exemplo n.º 2
0
 /**
  * Remove old values from the Session’s flash data.
  */
 public static function flush()
 {
     // Make sure the session is started
     s::start();
     // Retrieve the flash data
     $registry = s::get(self::$namespace);
     // Clean up registry
     if (!empty($registry)) {
         foreach ($registry as $key => $expiry) {
             $expiry++;
             // Remove all old values from the session
             if ($expiry > 1) {
                 s::remove($key);
                 unset($registry[$key]);
             } else {
                 $registry[$key] = $expiry;
             }
         }
         // Write registry back to session
         if (!empty($registry)) {
             s::set(self::$namespace, $registry);
         } else {
             s::remove(self::$namespace);
         }
     }
 }
Exemplo n.º 3
0
 public static function get($name)
 {
     $messages = s::get('messages');
     foreach ($messages as $key => $message) {
         if ($message->name == $name) {
             return $message->value;
         }
     }
     s::remove('messages');
 }
Exemplo n.º 4
0
 /**
  * Deconstruct the order object
  *
  * @return void
  */
 public function deconstruct()
 {
     $this->emptyGuests();
     s::remove('order.comments');
     s::remove('order.couponCode');
 }
Exemplo n.º 5
0
 function testSessionRemove()
 {
     s::remove('key');
     $this->assertNull(s::get('key'));
 }
Exemplo n.º 6
0
</textarea>
						<?php 
    echo $validator->field_error('message');
    ?>
					</div>
				</div>
				<div class="field field-submit">
					<input type="submit" name="submit" class="btn" value="Send" />
				</div>
			</form>
		<?php 
} else {
    ?>
			<div class="sent">
				<h2>Thanks for getting in touch.</h2>
				<p>I will try to get back you you as soon as possible.</p>
			</div>
		<?php 
}
?>
	</div>
</div>

<?php 
echo snippet('content-types/social');
?>

<?php 
echo snippet('footer');
s::remove('email_sent');
Exemplo n.º 7
0
 /**
  * Instantiate the singleton
  *
  * @return void
  */
 protected function __construct()
 {
     static::$data = s::get('flash', []);
     s::remove('flash');
 }
Exemplo n.º 8
0
 public function reset()
 {
     return s::remove($this->id);
 }
Exemplo n.º 9
0
 if (count($_POST) > 0) {
     //store specific sanitized $_POST variables into resetData session variable
     s::set('resetData', r::postData(array('password', 'password2')));
     //store URI param variables into session variables
     s::set('username', $paramUsername);
     s::set('hash', $paramResetHash);
     //redirect to same page (POST/GET/REDIRECT PATTERN-like)
     header('HTTP/1.1 303 See Other');
     header('Location: ' . $page->url());
 } elseif (s::get('resetData')) {
     //store resetData session variable into $data
     $data = s::get('resetData');
     //remove session variables
     s::remove('resetData');
     s::remove('username');
     s::remove('hash');
     //define validation rules for $data
     $rules = array('password' => array('required', 'match' => c::get('password.length.regex')), 'password2' => array('required', 'same' => $data['password']));
     //define validation messages for $data
     $messages = array('password' => l('field.password.validaton.message'), 'password2' => l('field.password2.validaton.message'));
     //if validation is passed
     if (!($invalid = invalid(array_filter($data), $rules, $messages))) {
         //try to update user's account password
         $userUpdatedData = $user->update(array('password' => $data['password']));
         //if updating user's password was successful
         if ($userUpdatedData) {
             //set success message
             $success['Account'] = l('reset.success.update');
         } else {
             //add error: password update failed
             $invalid['Account'] = l('reset.fail.update');
Exemplo n.º 10
0
 public static function logout()
 {
     session_regenerate_id();
     s::remove('auth.created');
     s::remove('auth.updated');
     s::remove('auth.key');
     s::remove('auth.secret');
     s::remove('auth.username');
     s::remove('auth.ip');
     s::remove('auth.ua');
     cookie::remove('key');
 }
Exemplo n.º 11
0
 public function reset()
 {
     if ($this->field) {
         return $this->store()->reset();
     } else {
         foreach (s::get() as $key => $value) {
             if (str::startsWith($key, $this->id)) {
                 s::remove($key);
             }
         }
     }
 }
Exemplo n.º 12
0
<?php

s::remove('cart');
snippet('header');
?>

<main id="paid" class="main black" role="main">

	<div class="text">
		<h1><?php 
echo $page->subtitle()->or($page->title());
?>
</h1>
		<a class="btn-white" href="<?php 
echo url('products');
?>
">Acheter à nouveau ?</a>
	</div>

</main>

<?php 
snippet('footer');
Exemplo n.º 13
0
}
s::set('country', $country);
// Set discount code from query string or user profile
if ($code = get('dc') or $user = site()->user() and $code = $user->discountcode()) {
    s::set('discountCode', strtoupper($code));
} else {
    if (get('dc') === '') {
        s::remove('discountCode');
    }
}
// Set gift certificate code from query string
if ($code = get('gc')) {
    s::set('giftCertificateCode', strtoupper($code));
} else {
    if (get('gc') === '') {
        s::remove('giftCertificateCode');
    }
}
/**
 * Helper function to format price
 */
function formatPrice($number)
{
    $symbol = page('shop')->currency_symbol();
    $currencyCode = page('shop')->currency_code();
    if (page('shop')->currency_position() == 'before') {
        return '<span property="priceCurrency" content="' . $currencyCode . '">' . $symbol . '</span> <span property="price" content="' . number_format((double) $number, 2, '.', '') . '">' . number_format((double) $number, 2, '.', '') . '</span>';
    } else {
        return number_format($number, 2, '.', '') . '&nbsp;' . $symbol;
    }
}
Exemplo n.º 14
0
 $user = null;
 $data = null;
 $invalid = null;
 $success = null;
 //if $_POST data is present
 if (count($_POST) > 0) {
     //store specific sanitized $_POST variables into registerData session variable
     s::set('registerData', r::postData(array('email', 'password', 'password2', 'session')));
     //redirect to same page (POST/GET/REDIRECT PATTERN-like)
     header('HTTP/1.1 303 See Other');
     header('Location: ' . $page->url());
 } elseif (s::get('registerData')) {
     //store registerData session variable into $data varaiable
     $data = s::get('registerData');
     //unset $registerData session variable
     s::remove('registerData');
     //define validation rules for $data
     $rules = array('email' => array('required', 'email'), 'password' => array('required', 'match' => c::get('password.length.regex')), 'password2' => array('required', 'same' => $data['password']), 'session' => array('required'));
     //define validation messages for $data
     $messages = array('email' => l('field.email.validation.message'), 'password' => l('field.password.validaton.message'), 'password2' => l('field.password2.validaton.message'), 'session' => l('field.session.validaton.message'));
     //if validation is passed
     if (!($invalid = invalid(array_filter($data), $rules, $messages))) {
         //compute user's username (based upon user's email)
         $computedUsername = Auth::computeUsername($data['email']);
         //**** USER DATA****************************************************************************
         //user's computed name
         $paramUsername = $computedUsername;
         //user's password (will be encrypted by KIRBY)
         $paramPassword = $data['password'];
         //user's email
         $paramEmail = $data['email'];
Exemplo n.º 15
0
<?php

// Check if user is coming from the cart page or from PayPal
s::start();
if (s::get('sendBack')) {
    // If coming from PayPal, kick them back to the cart
    s::remove('sendBack');
    go('shop/cart');
} else {
    s::set('sendBack', true);
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<title><?php 
echo site()->title()->html();
?>
 | <?php 
echo page('shop/cart')->title();
?>
</title>
	<style>
		body { font-family: sans-serif; font-size: 2rem; text-align: center; }
		button { font-size: 1rem; padding: 1rem; }
	</style>
</head>
<body>
	<p><?php 
Exemplo n.º 16
0
 //if a user is currently logged
 if ($user) {
     //get user's subscribed session
     $userTestSession = $pages->find(implode(DS, array(c::get('sessions.folder'), $user->session())));
     //if $_POST data is present
     if (count($_POST) > 0) {
         //store specific sanitized $_POST variables into editData session variable
         s::set('editData', r::postData(array('password', 'password2')));
         //redirect to same page (POST/GET/REDIRECT PATTERN-like)
         header('HTTP/1.1 303 See Other');
         header('Location: ' . $page->url());
     } elseif (s::get('editData')) {
         //store editData session variable into $data
         $data = s::get('editData');
         //unset editData session variable
         s::remove('editData');
         //define validation rules for $data
         $rules = array('password' => array('required', 'match' => c::get('password.length.regex')), 'password2' => array('required', 'same' => $data['password']));
         //define validation messages for $data
         $messages = array('password' => l('field.password.validaton.message'), 'password2' => l('field.password2.validaton.message'));
         //edit user only if validation is passed
         if (!($invalid = invalid(array_filter($data), $rules, $messages))) {
             //store user's old password
             $oldPassword = $user->password();
             //update user's password
             $userUpdatedData = $user->update(array('password' => $data['password']));
             //if user's password update was successful
             if ($userUpdatedData->password() != $oldPassword) {
                 //set success message
                 $success['Account'] = l('edit.success.passwordUpdate');
             } else {
Exemplo n.º 17
0
 public static function unauthorize()
 {
     s::remove('kirby_auth_secret');
     s::remove('kirby_auth_username');
     cookie::remove('kirby_auth');
 }
Exemplo n.º 18
0
 /**
  * Retrieves an item and removes it afterwards
  * 
  * @param string $key
  * @param mixed $default
  * @return mixed
  */
 public static function pull($key, $default = null)
 {
     $value = s::get($key, $default);
     s::remove($key);
     return $value;
 }
Exemplo n.º 19
0
 /**
  * Destroys the current token of this form.
  */
 private function destroyToken()
 {
     s::remove($this->id);
 }
Exemplo n.º 20
0
 /**
  * Instantiate the singleton
  *
  * @return void
  */
 private function __construct($session_key = '_flash')
 {
     self::setSessionKey($session_key);
     static::$data = Session::get(self::sessionKey(), []);
     Session::remove(self::sessionKey());
 }