当前位置: 首页>>代码示例>>PHP>>正文


PHP Cookie::setName方法代码示例

本文整理汇总了PHP中Cookie::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Cookie::setName方法的具体用法?PHP Cookie::setName怎么用?PHP Cookie::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cookie的用法示例。


在下文中一共展示了Cookie::setName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Cookie

 /**
  * Creates a cookie object, adds it to the cookies stack and returns an reference to this cookie
  *
  * @param string $name
  *            Name of cookie to create
  *
  * @return \Core\Http\Cookie\CookieInterface
  */
 public function &createCookie(string $name)
 {
     $cookie = new Cookie();
     $cookie->setName($name);
     $this->addCookie($cookie);
     return $cookie;
 }
开发者ID:tekkla,项目名称:core-http,代码行数:15,代码来源:CookieHandler.php

示例2: doRun

function doRun()
{
    $msg = '';
    $username = mysql_real_escape_string($_POST['name']);
    $pass = mysql_real_escape_string($_POST['pass']);
    try {
        $db = new PDO('mysql:host=localhost;dbname=testData', 'root', 'root');
        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $stmt = $db->prepare('	SELECT 
													username, pass 
											FROM 	
													testTable
											WHERE
													username = :name
											AND 	
													pass = :pass

										');
        $stmt->bindParam(':name', $username, PDO::PARAM_STR);
        $stmt->bindParam(':pass', $pass, PDO::PARAM_STR);
        $stmt->execute();
        $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
        if ($result == false) {
            $msg = 'sorry could not connect';
        } else {
            //$_SESSION['name'] = $username;
            /**
             * Create a cookie with the name "myCookieName" and value "testing cookie value"
             */
            $cookie = new Cookie();
            // Set cookie name
            $cookie->setName('Login');
            // Set cookie value
            $cookie->setValue("testing cookie value");
            // Set cookie expiration time
            $cookie->setTime("+1 hour");
            // Create the cookie
            $cookie->create();
            // Delete the cookie.
            //$cookie->delete();
            $msg = 'logged in as ' . $username . '<br>';
        }
    } catch (PDOException $e) {
        echo "Error:" . $e;
    }
    echo $msg;
    $db = NULL;
}
开发者ID:reshadf,项目名称:Library,代码行数:48,代码来源:index.php

示例3: setCookie

 public static function setCookie($user, $name, $value, $expires)
 {
     //self::cleanCookies();
     $cookie = self::getCookieObject($user, $name);
     if ($cookie) {
         $cookie->setValue($value);
         $cookie->setExpires(date("Y-m-d H:i:s", $expires));
         $cookie->save();
     } else {
         $cookie = new Cookie();
         $cookie->setUserId($user->getId());
         $cookie->setName($name);
         $cookie->setValue($value);
         $cookie->setExpires(date("Y-m-d H:i:s", $expires));
         $cookie->save();
     }
 }
开发者ID:auphau,项目名称:joyreactor,代码行数:17,代码来源:Cookie.class.php


注:本文中的Cookie::setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。