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


PHP Session类代码示例

本文整理汇总了PHP中Session的典型用法代码示例。如果您正苦于以下问题:PHP Session类的具体用法?PHP Session怎么用?PHP Session使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getHtml

    public function getHtml()
    {
        $transHtml = array();
        $request = $this->controller->getRequest();
        if ($this->controller instanceof CheckoutController && $request->getActionName() == 'completed') {
            $session = new Session();
            if ($orderID = $session->get('completedOrderID')) {
                $order = CustomerOrder::getInstanceByID((int) $session->get('completedOrderID'), CustomerOrder::LOAD_DATA);
                $order->loadAll();
                $orderArray = $order->toArray();
                $data = array($order->getID(), '', $orderArray['total'][$orderArray['Currency']['ID']], $order->getTaxAmount(), $orderArray['ShippingAddress']['city'], $orderArray['ShippingAddress']['stateName'], $orderArray['ShippingAddress']['countryID']);
                $transHtml[] = 'pageTracker._addTrans' . $this->getJSParams($data);
                foreach ($orderArray['cartItems'] as $item) {
                    $data = array($order->getID(), $item['Product']['sku'], $item['Product']['name'], $item['Product']['Category']['name'], $item['price'], $item['count']);
                    $transHtml[] = 'pageTracker._addItem' . $this->getJSParams($data);
                }
            }
            $transHtml[] = 'pageTracker._trackTrans();';
        }
        return '<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("' . $this->getValue('code') . '");
pageTracker._initData();
pageTracker._trackPageview();
' . implode("\n", $transHtml) . '
</script>';
    }
开发者ID:saiber,项目名称:livecart,代码行数:30,代码来源:GoogleAnalytics.php

示例2: login

 public static function login($username, $password, $language)
 {
     if ($username and $password) {
         $auth = new Auth();
         if ($auth->login($username, $password) == true) {
             $session_id = $auth->get_session_id();
             $session = new Session($session_id);
             $user = new User($session->get_user_id());
             $regional = new Regional($session->get_user_id());
             if (is_numeric($language)) {
                 $session->write_value("LANGUAGE", $language);
             } else {
                 $session->write_value("LANGUAGE", $regional->get_language_id());
             }
             if ($user->get_boolean_user_entry("user_locked") == false) {
                 return "index.php?username=" . $username . "&session_id=" . $session_id;
             } else {
                 return 0;
             }
         } else {
             return 0;
         }
     } else {
         return 0;
     }
 }
开发者ID:suxinde2009,项目名称:www,代码行数:26,代码来源:login.ajax.php

示例3: login

 private function login()
 {
     $session = new Session();
     if (!$session->has('documentsUser')) {
         $this->redirect('dokumenty-login.html', true);
     }
 }
开发者ID:posiadacz,项目名称:wsm,代码行数:7,代码来源:DocumentsController.php

示例4: app_start

function app_start()
{
    // Create a new instance of the Session object, and get the channel information.
    $session = new Session();
    $from_info = $session->getFrom();
    $network = $from_info['channel'];
    // Create a new instance of the Tropo object.
    $tropo = new Tropo();
    // See if any text was sent with session start.
    $initial_text = $session->getInitialText();
    // If the initial text is a zip code, skip the input collection and go right to results.
    if (strlen($initial_text) == 1 && is_numeric($initial_text)) {
        valid_text($tropo, $initial_text);
    } else {
        // Welcome prompt.
        $tropo->say("Welcome to the Tropo PHP example for {$network}");
        // Set up options for input.
        $options = array("attempts" => 3, "bargein" => true, "choices" => "1,2,3,4", "mode" => "dtmf", "name" => "movie", "timeout" => 30);
        // Ask the caller for input, pass in options.
        $tropo->ask("Which of these trilogies do you like the best?  Press 1 to vote for Lord of the Rings, press 2 for the original Star Wars, 3 for the Star Wars prequels, or press 4 for the Matrix", $options);
        // Tell Tropo what to do when the user has entered input, or if there's a problem. This redirects to the instructions under dispatch_post('/choice', 'app_choice') or dispatch_post('/incomplete', 'app_incomplete').
        $tropo->on(array("event" => "continue", "next" => "favorite-movie-webapi.php?uri=choice", "say" => "Please hold."));
        $tropo->on(array("event" => "incomplete", "next" => "favorite-movie-webapi.php?uri=incomplete"));
    }
    // Render the JSON for the Tropo WebAPI to consume.
    return $tropo->RenderJson();
}
开发者ID:MeiTen,项目名称:tropo-webapi-php,代码行数:27,代码来源:favorite-movie-webapi.php

示例5: Create

 public static function Create($p_sessionId, &$p_objectId, $p_objectTypeId = null, $p_userId = null, $p_updateStats = false)
 {
     if (empty($p_sessionId)) {
         throw new SessionIdNotSet();
     }
     $session = new Session($p_sessionId);
     if (!$session->exists()) {
         $sessionParams = array('start_time' => strftime("%Y-%m-%d %T"));
         if (!empty($p_userId)) {
             $sessionParams['user_id'] = $p_userId;
         }
         $session->create($sessionParams);
     }
     $sessionUserId = $session->getUserId();
     if (!empty($p_userId) && !empty($sessionUserId) && $sessionUserId != $p_userId) {
         throw new InvalidUserId();
     }
     $requestObject = new RequestObject($p_objectId);
     if (!$requestObject->exists()) {
         if (empty($p_objectTypeId)) {
             throw new ObjectTypeIdNotSet();
         }
         $requestObject->create(array('object_type_id' => $p_objectTypeId));
         $p_objectId = $requestObject->getObjectId();
     } elseif (empty($p_objectId)) {
         throw new ObjectIdNotSet();
     }
     if ($p_updateStats) {
         self::UpdateStats($p_sessionId, $p_objectId);
     }
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:31,代码来源:SessionRequest.php

示例6: testGetShellInterpreter

 public function testGetShellInterpreter()
 {
     $instance = new Session(__FILE__);
     $shellInterpreter1 = $instance->getShellInterpreter();
     $shellInterpreter2 = $instance->getShellInterpreter();
     $this->assertSame($shellInterpreter1, $shellInterpreter2);
 }
开发者ID:mlessnau,项目名称:pry,代码行数:7,代码来源:SessionTest.php

示例7: getMessage

 /**
  * Obtém mensagem contida na sessão
  * 
  * @return string
  */
 public function getMessage()
 {
     $sessao = new Session();
     $message = $sessao->get(self::_NAMESPACE);
     self::clear();
     return $message;
 }
开发者ID:brgomes,项目名称:life-framework,代码行数:12,代码来源:FlashMessenger.php

示例8: __construct

 function __construct()
 {
     parent::__construct();
     $session = new Session();
     $getSessi = $session->get_session();
     $this->user = $getSessi[0];
 }
开发者ID:TrinataBhayanaka,项目名称:ibc.resource,代码行数:7,代码来源:helper_model.php

示例9: testRemoveAll

 /**
  * @covers \Heystack\Core\State\Backends\Session::setSession
  * @covers \Heystack\Core\State\Backends\Session::getKeys
  * @covers \Heystack\Core\State\Backends\Session::removeAll
  * @covers \Heystack\Core\State\Backends\Session::removeByKey
  */
 public function testRemoveAll()
 {
     $session = new Session();
     $session->setSession(new \Session(['test' => 'hello']));
     $session->removeAll();
     $this->assertNull($session->getByKey('test'));
 }
开发者ID:helpfulrobot,项目名称:heystack-heystack,代码行数:13,代码来源:SessionTest.php

示例10: buildData

    protected function buildData() {
        $builders = array();

        //Add owner
        $session = new Session();
        $cryptpass = $session->pwdcrypt("oldpassword");
        $builders[] = FixtureBuilder::build('owners', array('id'=>1, 'full_name'=>'ThinkUp J. User',
        'email'=>'me@example.com', 'is_activated'=>1, 'pwd'=>$cryptpass));

        $builders[] = FixtureBuilder::build('owners', array('id'=>2, 'full_name'=>'ThinkUp J. Admin',
        'email'=>'admin@example.com', 'is_activated'=>1, 'is_admin'=>1));

        //Add instance_owner
        $builders[] = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>1));
        $builders[] = FixtureBuilder::build('owner_instances', array('owner_id'=>2, 'instance_id'=>1));

        //Insert test data into test table
        $builders[] = FixtureBuilder::build('users', array('user_id'=>13, 'user_name'=>'ev',
        'full_name'=>'Ev Williams'));

        //Make public
        //Insert test data into test table
        $builders[] = FixtureBuilder::build('instances', array('id'=>1, 'network_user_id'=>13,
        'network_username'=>'ev', 'is_public'=>1, 'network'=>'twitter'));

        return $builders;
    }
开发者ID:rgoncalves,项目名称:ThinkUp,代码行数:27,代码来源:TestOfAccountConfigurationController.php

示例11: newSession

 /** Creates a new session. */
 public static function newSession($assignment_id, $worker_id, Game $game)
 {
     $new_session = new Session();
     $new_session->id = uniqid('', true);
     $new_session->assignment_id = $assignment_id;
     $new_session->worker_id = $worker_id;
     $new_session->game = $game;
     $new_session->current_step = $game->steps[0];
     $new_session->repetition = 0;
     $new_session->data = array();
     $new_session->status = self::awaiting_user_input;
     $new_session->setExpiration($new_session->current_step->time_limit);
     $dbh = Database::handle();
     $sth = $dbh->prepare('INSERT INTO sessions ' . '(session_id, assignment_id, worker_id, game, data, status, expires) ' . 'VALUES ' . '(:session, :assignment, :worker, :game, :data, :status, :expires)');
     $sth->bindValue(':session', $new_session->id);
     $sth->bindValue(':assignment', $new_session->assignment_id);
     $sth->bindValue(':worker', $new_session->worker_id);
     $sth->bindValue(':game', $new_session->game->getID());
     $sth->bindValue(':data', serialize($new_session->data));
     $sth->bindValue(':status', $new_session->status);
     $sth->bindValue(':expires', $new_session->expires);
     $sth->execute();
     self::$sessions[$new_session->id] = $new_session;
     return self::$sessions[$new_session->id];
 }
开发者ID:nmalkin,项目名称:basset,代码行数:26,代码来源:session.php

示例12: SetData

 /** @param string[] $data */
 public function SetData($data)
 {
     if (isset($data['baseIngredientID'])) {
         if ($data['baseIngredientID']) {
             $baseIngredient = $this->Session->IngredientByID($data['baseIngredientID']);
             if (!$baseIngredient) {
                 APIResponse(RESPONSE_400, "Update Ingredient with bad base ingredient ID.");
             } else {
                 $this->BaseIngredient = $baseIngredient;
             }
         } else {
             $this->BaseIngredient = false;
         }
     }
     if (isset($data['id'])) {
         $this->ID = (int) $data['id'];
     }
     if (isset($data['title'])) {
         $this->Title = $data['title'];
     }
     if (isset($data['type'])) {
         $this->Type = $data['type'];
     }
     if (isset($data['description'])) {
         $this->Description = $data['description'];
     }
 }
开发者ID:bnorm-software,项目名称:barkeep-backend,代码行数:28,代码来源:CLASS_Ingredient.php

示例13: __construct

 /**
  * Constructor.
  *
  * @param SessionInterface    $session
  * @param TranslatorInterface $translator
  */
 public function __construct(SessionInterface $session, TranslatorInterface $translator)
 {
     $this->session = $session;
     $this->translator = $translator;
     /* @var SessionBagInterface flashBag */
     $this->flashBag = $this->session->getFlashBag();
 }
开发者ID:whte-rbt,项目名称:foundation-bundle,代码行数:13,代码来源:AbstractFlashSubscriber.php

示例14: RecupPodcast

 public function RecupPodcast($object)
 {
     //session_start();
     $pseudo = 'pseudo';
     $object = strtolower($object);
     $sess = new Session();
     $user_session = $sess->__get($pseudo);
     echo 'type :' . gettype($user_session) . '<br/>';
     $yy = var_dump($user_session);
     if ($object == "url") {
         try {
             $req = $this->db->query("SELECT url as lurl FROM podcast p, preference p, utilisateur u WHERE pseudo='{$user_session}' AND u.id_util=pref.id_util AND pref.id_genre=p.id_genre ");
             $req = $req->fetch_object()->lurl;
             echo $req;
         } catch (Exception $e) {
             echo "Une erreur est survenue !" . $e->getMessage();
         }
     } else {
         if (strtolower($object) == "prenom" || strtolower($object) == "prénom") {
             try {
                 $req = $this->db->query("SELECT u_prenom as leprenom FROM utilisateur WHERE pseudo='{$user_session}' ");
                 $req = $req->fetch_object()->leprenom;
             } catch (Exception $e) {
                 echo "Une erreur est survenue !" . $e->getMessage();
             }
         }
     }
     return $req;
 }
开发者ID:rafale57,项目名称:RaphMarwin,代码行数:29,代码来源:RecupUserPodcast.php

示例15: get

 /**
  * Returns the object of the active session.
  * Tries to find an existing session. 
  * Otherwise creates a new session.
  * 
  * @return 	 Session 		$session
  */
 public function get()
 {
     // get session id
     $this->sessionID = $this->readSessionID();
     $this->session = null;
     // get existing session
     if (!empty($this->sessionID)) {
         $this->session = $this->getExistingSession($this->sessionID);
     }
     // create new session
     if ($this->session == null) {
         $this->session = $this->create();
     }
     self::$activeSession = $this->session;
     // call shouldInit event
     if (!defined('NO_IMPORTS')) {
         EventHandler::fireAction($this, 'shouldInit');
     }
     // init session
     $this->session->init();
     // call didInit event
     if (!defined('NO_IMPORTS')) {
         EventHandler::fireAction($this, 'didInit');
     }
     return $this->session;
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:33,代码来源:SessionFactory.class.php


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