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


PHP Cookie::setValue方法代码示例

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


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

示例1: index

 /**
  * Return project messages
  *
  * @access public
  * @param void
  * @return array
  */
 function index()
 {
     $this->addHelper('textile');
     $page = (int) array_var($_GET, 'page', 1);
     if ($page < 0) {
         $page = 1;
     }
     $this->canGoOn();
     // Gets desired view 'detail' or 'list'
     // $view_type is from URL, Cookie or set to default: 'list'
     $view_type = array_var($_GET, 'view', Cookie::getValue('messagesViewType', 'list'));
     $expiration = Cookie::getValue('remember' . TOKEN_COOKIE_NAME) ? REMEMBER_LOGIN_LIFETIME : null;
     Cookie::setValue('messagesViewType', $view_type, $expiration);
     $period_type = array_var($_GET, 'period', Cookie::getValue('messagesPeriodType', 'fresh'));
     $expiration = Cookie::getValue('remember' . TOKEN_COOKIE_NAME) ? REMEMBER_LOGIN_LIFETIME : null;
     Cookie::setValue('messagesPeriodType', $period_type, $expiration);
     /* 
     	  
     	extended the time that project pier auto archives  
     */
     $archive_condition = ' AND `updated_on` >= (now() - interval 990 day)';
     if ($period_type == 'archive') {
         $archive_condition = ' AND `updated_on` < (now() - interval 990 day)';
     }
     $conditions = logged_user()->isMemberOfOwnerCompany() ? array('`project_id` = ?' . $archive_condition, active_project()->getId()) : array('`project_id` = ? AND `is_private` = ?' . $archive_condition, active_project()->getId(), 0);
     list($messages, $pagination) = ProjectMessages::paginate(array('conditions' => $conditions, 'order' => '`created_on` DESC'), config_option('messages_per_page', 10), $page);
     // paginate
     tpl_assign('view_type', $view_type);
     tpl_assign('period_type', $period_type);
     tpl_assign('messages', $messages);
     tpl_assign('messages_pagination', $pagination);
     tpl_assign('important_messages', active_project()->getImportantMessages());
     $this->setSidebar(get_template_path('index_sidebar', 'message'));
 }
开发者ID:D-L-C,项目名称:projectpeir-customization,代码行数:41,代码来源:MessageController.class.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

示例4: setLoggedUser

 /**
  * Set logged_user value
  *
  * @access public
  * @param User $value
  * @param boolean $remember Remember this user for 2 weeks (configurable)
  * @param DateTimeValue $set_last_activity_time Set last activity time. This property is turned off in case of feed 
  *   login for instance
  * @return null
  * @throws DBQueryError
  */
 function setLoggedUser(User $user, $remember = false, $set_last_activity_time = true)
 {
     if ($set_last_activity_time) {
         $user->setLastActivity(DateTimeValueLib::now());
         $user->save();
     }
     // if
     $expiration = $remember ? REMEMBER_LOGIN_LIFETIME : SESSION_LIFETIME;
     Cookie::setValue('id' . TOKEN_COOKIE_NAME, $user->getId(), $expiration);
     Cookie::setValue(TOKEN_COOKIE_NAME, $user->getTwistedToken(), $expiration);
     if ($remember) {
         Cookie::setValue('remember' . TOKEN_COOKIE_NAME, 1, $expiration);
     } else {
         Cookie::unsetValue('remember' . TOKEN_COOKIE_NAME);
     }
     // if
     $this->logged_user = $user;
 }
开发者ID:swenson,项目名称:projectpier,代码行数:29,代码来源:CompanyWebsite.class.php

示例5: deleteCookie

 /**
  * Deletes a cookie.
  * 
  * @param  Cookie $cookie
  * @return void
  */
 public function deleteCookie(Cookie $cookie)
 {
     $cookie->setValue('');
     $cookie->setMaxAge(-1);
     $this->cookies[$cookie->getName()] = $cookie;
 }
开发者ID:christophercutts,项目名称:tech-test,代码行数:12,代码来源:HttpResponse.php

示例6: setLoggedUser

 /**
  * Set logged_user value
  *
  * @access public
  * @param Contact $value
  * @param boolean $remember Remember this user for 2 weeks (configurable)
  * @param DateTimeValue $set_last_activity_time Set last activity time. This property is turned off in case of feed
  *   login for instance
  * @return null
  * @throws DBQueryError
  */
 function setLoggedUser(Contact $user, $remember = false, $set_last_activity_time = true, $set_cookies = true)
 {
     if ($set_last_activity_time) {
         $last_activity_mod_timestamp = array_var($_SESSION, 'last_activity_mod_timestamp', null);
         if (!$last_activity_mod_timestamp || $last_activity_mod_timestamp < time() - 60 * 10) {
             $sql = "UPDATE " . TABLE_PREFIX . "contacts SET last_activity = '" . DateTimeValueLib::now()->toMySQL() . "' WHERE object_id = " . $user->getId();
             DB::execute($sql);
             $_SESSION['last_activity_mod_timestamp'] = time();
         }
     }
     if ($set_cookies) {
         $expiration = $remember ? REMEMBER_LOGIN_LIFETIME : SESSION_LIFETIME;
         Cookie::setValue('id', $user->getId(), $expiration);
         Cookie::setValue('token', $user->getTwistedToken(), $expiration);
         if ($remember) {
             Cookie::setValue('remember', 1, $expiration);
         } else {
             Cookie::unsetValue('remember');
         }
         // if
     }
     $this->logged_user = $user;
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:34,代码来源:CompanyWebsite.class.php

示例7: setLoggedUser

 /**
  * Set logged_user value
  *
  * @access public
  * @param Contact $value
  * @param boolean $remember Remember this user for 2 weeks (configurable)
  * @param DateTimeValue $set_last_activity_time Set last activity time. This property is turned off in case of feed
  *   login for instance
  * @return null
  * @throws DBQueryError
  */
 function setLoggedUser(Contact $user, $remember = false, $set_last_activity_time = true, $set_cookies = true)
 {
     if ($set_last_activity_time) {
         $last_activity_mod_timestamp = array_var($_SESSION, 'last_activity_mod_timestamp', null);
         if (!isset($_SESSION['last_activity_updating']) && (!$last_activity_mod_timestamp || $last_activity_mod_timestamp < time() - 60 * 10)) {
             $_SESSION['last_activity_updating'] = true;
             $now = DateTimeValueLib::now();
             if (is_null($user->getLastActivity())) {
                 $last_visit = $now;
             } else {
                 $last_visit = $user->getLastActivity();
             }
             $sql = "UPDATE " . TABLE_PREFIX . "contacts SET last_activity = '" . $now->toMySQL() . "',\r\n\t\t\t\t \t\tlast_visit = '" . ($last_visit instanceof DateTimeValue ? $last_visit->toMySQL() : EMPTY_DATETIME) . "', last_login='" . $now->toMySQL() . "'\r\n\t\t\t\t \t\tWHERE object_id = " . $user->getId();
             DB::execute($sql);
             $_SESSION['last_activity_mod_timestamp'] = time();
             unset($_SESSION['last_activity_updating']);
         }
     }
     if ($set_cookies) {
         $expiration = $remember ? REMEMBER_LOGIN_LIFETIME : SESSION_LIFETIME;
         Cookie::setValue('id', $user->getId(), $expiration);
         Cookie::setValue('token', $user->getTwistedToken(), $expiration);
         if ($remember) {
             Cookie::setValue('remember', 1, $expiration);
         } else {
             Cookie::unsetValue('remember');
         }
         // if
     }
     $this->logged_user = $user;
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:42,代码来源:CompanyWebsite.class.php

示例8: weekly_schedule

 /**
  * Shows weekly schedule in a calendar view
  * 
  * @param void
  * @return null
  */
 function weekly_schedule()
 {
     $this->addHelper('textile');
     // Gets desired view 'detail', 'list' or 'calendar'
     // $view_type is from URL, Cookie or set to default: 'calendar'
     $view_type = array_var($_GET, 'view', Cookie::getValue('weeklyScheduleViewType', 'calendar'));
     $expiration = Cookie::getValue('remember' . TOKEN_COOKIE_NAME) ? REMEMBER_LOGIN_LIFETIME : null;
     Cookie::setValue('weeklyScheduleViewType', $view_type, $expiration);
     $monthYear = array_var($_GET, 'month');
     if (!isset($monthYear) || trim($monthYear) == '' || preg_match('/^(\\d{4})(\\d{2})$/', $monthYear, $matches) == 0) {
         $year = gmdate('Y');
         $month = gmdate('m');
     } else {
         list(, $year, $month) = $matches;
     }
     // TODO make first day of week configurable
     $from_date = DateTimeValueLib::makeFromString('monday' . (date('w') == 1 ? '' : ' last week'));
     $to_date = $from_date->advance(60 * 60 * 24 * 7 * 3, false);
     // +3 weeks
     $upcoming_milestones = ProjectMilestones::getActiveMilestonesInPeriodByUser(logged_user(), $from_date, $to_date);
     $upcoming_tickets = array();
     if (plugin_active('tickets')) {
         $upcoming_tickets = ProjectTickets::getOpenTicketsInPeriodByUser(logged_user(), $from_date, $to_date);
     }
     $active_projects = array();
     $projects_index = array();
     $counter = 1;
     if (is_array($upcoming_milestones)) {
         foreach ($upcoming_milestones as $milestone) {
             if (!isset($projects_index[$milestone->getProjectId()])) {
                 $projects_index[$milestone->getProjectId()] = $counter;
                 $active_projects[] = $milestone->getProject();
                 $counter++;
             }
             // if
         }
         // foreach
     }
     // if
     if (is_array($upcoming_tickets)) {
         foreach ($upcoming_tickets as $ticket) {
             if (!isset($projects_index[$ticket->getProjectId()])) {
                 $projects_index[$ticket->getProjectId()] = $counter;
                 $active_projects[] = $ticket->getProject();
                 $counter++;
             }
             // if
         }
         // foreach
     }
     // if
     tpl_assign('from_date', $from_date);
     tpl_assign('to_date', $to_date);
     tpl_assign('view_type', $view_type);
     tpl_assign('upcoming_tickets', $upcoming_tickets);
     tpl_assign('late_tickets', array());
     // logged_user()->getLateTickets());
     tpl_assign('upcoming_milestones', $upcoming_milestones);
     tpl_assign('late_milestones', array());
     // logged_user()->getLateMilestones());
     tpl_assign('projects', $active_projects);
     tpl_assign('projects_index', $projects_index);
 }
开发者ID:federosky,项目名称:ProjectPier-Core,代码行数:69,代码来源:DashboardController.class.php

示例9: setLoggedUser

 /**
  * Set logged_user value
  *
  * @access public
  * @param User $value
  * @param boolean $remember Remember this user 
  * @param boolean $set_last_activity_time Turned off in case of feed login
  * @return null
  * @throws DBQueryError
  */
 function setLoggedUser(User $user, $remember = false, $set_last_activity_time = true, $set_cookies = true)
 {
     trace(__FILE__, 'setLoggedUser():begin');
     if ($set_last_activity_time) {
         $user->setLastActivity(DateTimeValueLib::now());
         trace(__FILE__, 'setLoggedUser():user->save()');
         $user->save();
     }
     // if
     if ($set_cookies) {
         $expiration = $remember ? config_option('remember_login_lifetime', 3600) : 3600;
         Cookie::setValue('id' . TOKEN_COOKIE_NAME, $user->getId(), $expiration);
         Cookie::setValue(TOKEN_COOKIE_NAME, $user->getTwistedToken(), $expiration);
         if ($remember) {
             Cookie::setValue('remember' . TOKEN_COOKIE_NAME, 1, $expiration);
         } else {
             Cookie::unsetValue('remember' . TOKEN_COOKIE_NAME);
         }
         // if
     }
     // if
     trace(__FILE__, 'setLoggedUser():end');
     $this->logged_user = $user;
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:34,代码来源:CompanyWebsite.class.php

示例10: index

 /**
  * Return project tickets
  *
  * @access public
  * @param void
  * @return array
  */
 function index()
 {
     $page = (int) array_var($_GET, 'page', 1);
     if ($page < 0) {
         $page = 1;
     }
     $this->canGoOn();
     $params = array();
     $params['sort_by'] = array_var($_GET, 'sort_by', Cookie::getValue('ticketsSortBy', 'id'));
     $expiration = Cookie::getValue('remember' . TOKEN_COOKIE_NAME) ? REMEMBER_LOGIN_LIFETIME : null;
     Cookie::setValue('ticketsSortBy', $params['sort_by'], $expiration);
     $conditions = DB::prepareString('`project_id` = ?', array(active_project()->getId()));
     if ($params['status'] = array_var($_GET, 'status')) {
         $conditions .= DB::prepareString(' AND `state` IN (?)', array(explode(',', $params['status'])));
     }
     // if
     if ($params['priority'] = array_var($_GET, 'priority')) {
         $conditions .= DB::prepareString(' AND `priority` IN (?)', array(explode(',', $params['priority'])));
     }
     // if
     if ($params['type'] = array_var($_GET, 'type')) {
         $conditions .= DB::prepareString(' AND `type` IN (?)', array(explode(',', $params['type'])));
     }
     // if
     if ($params['category_id'] = array_var($_GET, 'category_id')) {
         $conditions .= DB::prepareString(' AND `category_id` IN (?)', array(explode(',', $params['category_id'])));
     }
     // if
     if ($params['assigned_to_user_id'] = array_var($_GET, 'assigned_to_user_id')) {
         $conditions .= DB::prepareString(' AND `assigned_to_user_id` IN (?)', array(explode(',', $params['assigned_to_user_id'])));
     }
     // if
     if ($params['created_by_id'] = array_var($_GET, 'created_by_id')) {
         $conditions .= DB::prepareString(' AND `created_by_id` IN (?)', array(explode(',', $params['created_by_id'])));
     }
     // if
     $params['order'] = array_var($_GET, 'order') != 'DESC' ? 'ASC' : 'DESC';
     $filtered = $params['status'] != "" || $params['priority'] != "" || $params['type'] != "" || $params['category_id'] != "" || $params['assigned_to_user_id'] != "" || $params['created_by_id'] != "";
     // Clean up empty and malformed parameters
     foreach ($params as $key => $value) {
         $value = preg_replace("/,+/", ",", $value);
         // removes multiple commas
         $value = preg_replace("/^,?(.*),?\$/", "\$1", $value);
         // removes commas at both ends
         $params[$key] = $value;
         if ($value == "") {
             unset($params[$key]);
             // deletes empty keys
         }
         // if
     }
     // foreach
     $order = '`' . $params['sort_by'] . '` ' . $params['order'] . '';
     if (!logged_user()->isMemberOfOwnerCompany()) {
         $conditions .= DB::prepareString(' AND `is_private` = ?', array(0));
     }
     // if
     list($tickets, $pagination) = ProjectTickets::paginate(array('conditions' => $conditions, 'order' => $order), config_option('tickets_per_page', 25), $page);
     // paginate
     tpl_assign('filtered', $filtered);
     tpl_assign('params', $params);
     tpl_assign('grouped_users', active_project()->getUsers(true));
     tpl_assign('categories', ProjectCategories::getProjectCategories(active_project()));
     tpl_assign('tickets', $tickets);
     tpl_assign('tickets_pagination', $pagination);
     $this->setSidebar(get_template_path('index_sidebar', 'tickets'));
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:74,代码来源:TicketsController.class.php

示例11: calendar

 /**
  * Show calendar view milestone page
  *
  * @access public
  * @param void
  * @return null
  */
 function calendar()
 {
     $this->addHelper('textile');
     $project = active_project();
     $id = get_id();
     if (strlen($id) == 0) {
         $id = gmdate('Ym');
     }
     if (preg_match('/^(\\d{4})(\\d{2})$/', $id, $matches)) {
         list(, $year, $month) = $matches;
         tpl_assign('year', $year);
         tpl_assign('month', $month);
     } else {
         flash_error(lang('id missing'));
         $this->redirectToReferer(get_url('milestone', 'index'));
     }
     $view_type = array_var($_GET, 'view', Cookie::getValue('milestonesViewType', 'list'));
     $expiration = Cookie::getValue('remember' . TOKEN_COOKIE_NAME) ? REMEMBER_LOGIN_LIFETIME : null;
     Cookie::setValue('milestonesViewType', $view_type, $expiration);
     tpl_assign('view_type', $view_type);
     tpl_assign('milestones', $project->getMilestonesByMonth($year, $month));
     tpl_assign('task_lists', $project->getTaskListsByMonth($year, $month));
 }
开发者ID:federosky,项目名称:ProjectPier-Core,代码行数:30,代码来源:MilestoneController.class.php

示例12: setLoggedUser

 /**
  * Set logged_user value
  *
  * @access public
  * @param User $value
  * @param boolean $remember Remember this user for 2 weeks (configurable)
  * @param DateTimeValue $set_last_activity_time Set last activity time. This property is turned off in case of feed
  *   login for instance
  * @return null
  * @throws DBQueryError
  */
 function setLoggedUser(User $user, $remember = false, $set_last_activity_time = true, $set_cookies = true)
 {
     if ($set_last_activity_time) {
         $last_activity_mod_timestamp = array_var($_SESSION, 'last_activity_mod_timestamp', null);
         if (!$last_activity_mod_timestamp || $last_activity_mod_timestamp < time() - 60 * 10) {
             $user->setLastActivity(DateTimeValueLib::now());
             // Disable updating user info
             $old_updated_on = $user->getUpdatedOn();
             $user->setUpdatedOn(DateTimeValueLib::now());
             $user->setUpdatedOn($old_updated_on);
             $user->save();
             $_SESSION['last_activity_mod_timestamp'] = time();
         }
     }
     // if
     if ($set_cookies) {
         $expiration = $remember ? REMEMBER_LOGIN_LIFETIME : SESSION_LIFETIME;
         Cookie::setValue('id', $user->getId(), $expiration);
         Cookie::setValue('token', $user->getTwistedToken(), $expiration);
         Cookie::setValue('cn', md5(array_var($_SERVER, 'REMOTE_ADDR', "")));
         if ($remember) {
             Cookie::setValue('remember', 1, $expiration);
         } else {
             Cookie::unsetValue('remember');
         }
         // if
     }
     $this->logged_user = $user;
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:40,代码来源:CompanyWebsite.class.php


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