当前位置: 首页>>代码示例>>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;未经允许,请勿转载。