當前位置: 首頁>>代碼示例>>PHP>>正文


PHP cookie::salt方法代碼示例

本文整理匯總了PHP中cookie::salt方法的典型用法代碼示例。如果您正苦於以下問題:PHP cookie::salt方法的具體用法?PHP cookie::salt怎麽用?PHP cookie::salt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cookie的用法示例。


在下文中一共展示了cookie::salt方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get

 /**
  * Fetch a cookie value, using the Input library.
  *
  * @param   string   cookie name
  * @param   mixed    default value
  * @param   boolean  use XSS cleaning on the value
  * @return  string
  */
 public static function get($name = NULL, $default = NULL, $xss_clean = FALSE)
 {
     // Return an array of all the cookies if we don't have a name
     if ($name === NULL) {
         $cookies = array();
         foreach ($_COOKIE as $key => $value) {
             $cookies[$key] = cookie::get($key, $default, $xss_clean);
         }
         return $cookies;
     }
     if (!isset($_COOKIE[$name])) {
         return $default;
     }
     // Get the cookie value
     $cookie = $_COOKIE[$name];
     // Find the position of the split between salt and contents
     $split = strlen(cookie::salt($name, NULL));
     if (isset($cookie[$split]) and $cookie[$split] === '~') {
         // Separate the salt and the value
         list($hash, $value) = explode('~', $cookie, 2);
         if (cookie::salt($name, $value) === $hash) {
             if ($xss_clean === TRUE and Kohana::config('core.global_xss_filtering') === FALSE) {
                 return Input::instance()->xss_clean($value);
             }
             // Cookie signature is valid
             return $value;
         }
         // The cookie signature is invalid, delete it
         cookie::delete($name);
     }
     return $default;
 }
開發者ID:webmatter,項目名稱:gallery3-contrib,代碼行數:40,代碼來源:cookie.php

示例2: start

 static function start($salt, $expire = null, $domain = null, $path = '/')
 {
     self::$salt = $salt;
     self::$expire = $expire;
     self::$domain = $domain;
     self::$path = $path;
 }
開發者ID:nyan-cat,項目名稱:easyweb,代碼行數:7,代碼來源:cookie.php

示例3: set

 /**
  * Sets a signed cookie.
  *
  * @param   string   name of cookie
  * @param   string   contents of cookie
  * @param   integer  lifetime in seconds
  * @return  boolean
  */
 public static function set($key, $value, $expiration = NULL)
 {
     if ($expiration === NULL) {
         // Use the default expiration
         $expiration = cookie::$expiration;
     }
     if ($expiration !== 0) {
         // The expiration is expected to be a UNIX timestamp
         $expiration += time();
     }
     // Add the salt to the cookie value
     $value = cookie::salt($key, $value) . '~' . $value;
     return setcookie($key, $value, $expiration, cookie::$path, cookie::$domain, cookie::$secure, cookie::$httponly);
 }
開發者ID:ukd1,項目名稱:kohana,代碼行數:22,代碼來源:cookie.php

示例4: test_salt

	/**
	 * Tests cookie::salt()
	 *
	 * @test
	 * @dataProvider provider_salt
	 * @covers cookie::salt
	 * @param mixed   $key      key to use
	 * @param mixed   $value    value to salt with
	 * @param boolean $expected Output for cookie::delete()
	 */
	public function test_salt($key, $value, $expected)
	{
		$this->assertSame($expected, cookie::salt($key, $value));
	}
開發者ID:nevermlnd,項目名稱:cv,代碼行數:14,代碼來源:CookieTest.php

示例5: testLoggedInFromCookie

 /**
  * Test logged in from cookie
  */
 public function testLoggedInFromCookie()
 {
     DB::insert('users', array('id', 'username', 'token'))->values(array(2, 'logged_in_cookie_user', 1234))->execute();
     $_COOKIE['a1_a1_autologin'] = cookie::salt('a1_a1_autologin', '1234.2') . '~1234.2';
     $this->assertType('string', cookie::get('a1_a1_autologin'));
     $result = A1::instance('a1')->logged_in();
     $this->assertTrue($result);
     $session = Session::instance(Kohana::config('a1.session_type'));
     $user = $session->get('a1_a1');
     $this->assertType('object', $user);
     $this->assertEquals('logged_in_cookie_user', $user->username);
     $this->assertEquals(2, $user->id);
 }
開發者ID:vimofthevine,項目名稱:sentry,代碼行數:16,代碼來源:FunctionalTest.php


注:本文中的cookie::salt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。