本文整理汇总了PHP中lithium\storage\Session类的典型用法代码示例。如果您正苦于以下问题:PHP Session类的具体用法?PHP Session怎么用?PHP Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
public function post()
{
$token = Session::read('oauth.access');
$result = Consumer::post('/1/statuses/update.json', array('status' => 'Testing my status'), compact('token'));
echo $result;
exit;
}
示例2: check
public function check($credentials, array $options = array())
{
// This enables PHPBB login:
global $phpbb_root_path, $phpEx, $user, $auth, $template, $cache, $db, $config;
define('IN_PHPBB', true);
$phpbb_root_path = \app\util\Config::get('forum_path');
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include $phpbb_root_path . 'common.' . $phpEx;
// creates $user and $auth objects here.
$user->session_begin();
$logged_in = $user->data['is_registered'];
$username = strtolower($user->data['username_clean']);
if ($logged_in === false) {
// Not Logged In
return false;
}
$model = $this->_model;
$query = $this->_query;
$conditions = $this->_scope + array('prv_uid' => $username);
$id = $model::$query(compact('conditions'));
if (!$id) {
\lithium\storage\Session::write('non_linked_phpbb_login', true);
}
return $id;
}
示例3: _init
public function _init()
{
parent::_init();
if (!Session::read('user')) {
$this->redirect('Sessions::add');
}
}
示例4: index
public function index()
{
Header('Cache-Control: no-cache');
Header('Pragma: no-cache');
$this->_render['layout'] = 'dialog';
$apontador['token'] = Session::read('apontadorToken');
$apontador['name'] = Session::read('apontadorName');
$apontador['email'] = Session::read('apontadorEmail');
$apontador['logged'] = !empty($apontador['token']);
$foursquare['token'] = Session::read('foursquareToken');
$foursquare['name'] = Session::read('foursquareName');
$foursquare['email'] = Session::read('foursquareEmail');
$foursquare['logged'] = !empty($foursquare['token']);
$twitter['token'] = Session::read('twitterToken');
$twitter['name'] = Session::read('twitterName');
$twitter['logged'] = !empty($twitter['token']);
$facebook['token'] = Session::read('facebookToken');
$facebook['name'] = Session::read('facebookName');
$facebook['email'] = Session::read('facebookEmail');
$facebook['logged'] = !empty($facebook['token']);
$orkut['token'] = Session::read('orkutToken');
$orkut['name'] = Session::read('orkutName');
$orkut['email'] = Session::read('orkutEmail');
$orkut['logged'] = !empty($orkut['token']);
$title = "Configurações de conta";
return \array_merge(compact('title', 'apontador', 'foursquare', 'twitter', 'facebook', 'orkut'));
}
示例5: Rates
public function Rates($FirstCurrency = "BTC", $SecondCurrency = "USD")
{
$title = $FirstCurrency . "/" . $SecondCurrency;
$back = strtolower($FirstCurrency . "_" . $SecondCurrency);
$Refresh = "No";
$user = Session::read('member');
$id = $user['_id'];
$details = Details::find('first', array('conditions' => array('user_id' => $id)));
if ($details['page.refresh'] == true || $details['page.refresh'] == 1) {
$data = array('page.refresh' => false);
Details::find('all', array('conditions' => array('user_id' => $id)))->save($data);
$Refresh = "Yes";
}
$URL = "/" . $locale . 'ex/x/' . $back;
$trades = Trades::find('first', array('conditions' => array('trade' => $title)));
if ($trades['refresh'] == true || $trades['refresh'] == 1) {
$data = array('refresh' => false);
Trades::find('all', array('conditions' => array('trade' => $title)))->save($data);
$Refresh = "Yes";
}
$mongodb = Connections::get('default')->connection;
$Rates = Orders::connection()->connection->command(array('aggregate' => 'orders', 'pipeline' => array(array('$project' => array('_id' => 0, 'Action' => '$Action', 'PerPrice' => '$PerPrice', 'Completed' => '$Completed', 'FirstCurrency' => '$FirstCurrency', 'SecondCurrency' => '$SecondCurrency', 'TransactDateTime' => '$Transact.DateTime')), array('$match' => array('Completed' => 'Y', 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency)), array('$group' => array('_id' => array('year' => array('$year' => '$TransactDateTime'), 'month' => array('$month' => '$TransactDateTime'), 'day' => array('$dayOfMonth' => '$TransactDateTime')), 'min' => array('$min' => '$PerPrice'), 'max' => array('$max' => '$PerPrice'))), array('$sort' => array('_id.year' => -1, '_id.month' => -1, '_id.day' => -1)), array('$limit' => 1))));
// print_r($Rates['result']);
foreach ($Rates['result'] as $r) {
$Low = $r['min'];
$High = $r['max'];
}
$Last = Orders::find('all', array('conditions' => array('Completed' => 'Y', 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency), 'limit' => 1, 'order' => array('Transact.DateTime' => 'DESC')));
foreach ($Last as $l) {
$LastPrice = $l['PerPrice'];
}
$TotalOrders = Orders::connection()->connection->command(array('aggregate' => 'orders', 'pipeline' => array(array('$project' => array('_id' => 0, 'Action' => '$Action', 'Amount' => '$Amount', 'Completed' => '$Completed', 'FirstCurrency' => '$FirstCurrency', 'SecondCurrency' => '$SecondCurrency', 'TransactDateTime' => '$Transact.DateTime', 'TotalAmount' => array('$multiply' => array('$Amount', '$PerPrice')))), array('$match' => array('Completed' => 'Y', 'Action' => 'Buy', 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency)), array('$group' => array('_id' => array('year' => array('$year' => '$TransactDateTime'), 'month' => array('$month' => '$TransactDateTime')), 'Amount' => array('$sum' => '$Amount'), 'TotalAmount' => array('$sum' => '$TotalAmount'))), array('$sort' => array('_id.year' => -1, '_id.month' => -1)), array('$limit' => 1))));
// print_r($SecondCurrency);
return $this->render(array('json' => array('Refresh' => $Refresh, 'URL' => $URL, 'Low' => number_format($Low, 5), 'High' => number_format($High, 5), 'Last' => number_format($LastPrice, 5), 'VolumeFirst' => number_format($TotalOrders['result'][0]['Amount'], 5), 'VolumeSecond' => number_format($TotalOrders['result'][0]['TotalAmount'], 3), 'VolumeFirstUnit' => $FirstCurrency, 'VolumeSecondUnit' => $SecondCurrency)));
}
示例6: init
/**
* 初始化CSRF并检查token是否存在, 不存在则生成token
*/
public static function init()
{
$value = \lithium\storage\Session::read(self::$_session_key);
if (empty($value)) {
RequestToken::get();
}
}
示例7: login
public function login()
{
$token = Session::read("{$this->_config['namespace']}.request");
if (empty($token)) {
return $this->redirect('Client::authorize', array('exit' => true));
}
return $this->redirect(Consumer::authenticate($token), array('exit' => true));
}
示例8: array
function test_getFromSession()
{
Session::write(Trackers::$name, array(array('_trackPageview'), array('_setDomainName', 'example.org')), array('name' => 'default'));
Trackers::add('test', array('account' => 'test', 'adapter' => 'GoogleAnalytics', 'commands' => array(array('_setDomainName', 'example.org'))));
$expected = array(array('_setAccount', 'test'), array('_trackPageview'), array('_setDomainName', 'example.org'));
$tracking = Trackers::get('test');
$this->assertEqual($expected, $tracking->commands());
}
示例9: login
public function login()
{
$token = Session::read('oauth.request');
if (empty($token)) {
$this->redirect('Client::authorize');
}
$this->redirect(Consumer::authenticate($token));
}
示例10: login
public function login()
{
Session::delete('oauth.request');
Session::delete('oauth.access');
$token = Consumer::token('request', array('params' => array('oauth_callback' => 'http://local.moodpik.com/tweet/success')));
Session::write('oauth.request', $token);
if (empty($token)) {
$this->redirect('Tweet::authorize');
}
$this->redirect(Consumer::authenticate($token));
}
示例11: testWriteReadDelete
public function testWriteReadDelete()
{
$key = 'test';
$value = 'value';
Session::write($key, $value, array('name' => 'test'));
$result = Session::read($key, array('name' => 'test'));
$this->assertEqual($value, $result);
$this->assertTrue(Session::delete($key, array('name' => 'test')));
$result = Session::read($key, array('name' => 'test'));
$this->assertNull($result);
}
示例12: testBasicAuthCheck
public function testBasicAuthCheck()
{
$this->assertFalse(Auth::check('test'));
$user = array('user' => 'bob');
$result = Auth::check('test', $user, array('success' => true));
$this->assertEqual($user, $result);
$result = Session::read('test');
$this->assertEqual($user, $result);
$result = Auth::check('test');
$this->assertEqual($user, $result);
}
示例13: index
public function index()
{
$user = Session::read('default');
$id = $user['_id'];
$details = Details::find('first', array('conditions' => array('user_id' => (string) $id)));
$userInfo = Users::find('first', array('conditions' => array('_id' => (string) $id)));
$order = Orders::find('first', array('conditions' => array('user_id' => (string) $id, 'Completed' => 'N')));
$title = "API";
$keywords = "API, documentation, ibwt";
$description = "API documentation for ibwt.co.uk";
return compact('title', 'keywords', 'description', 'details', 'userInfo', 'order');
}
示例14: document
public function document()
{
$user = Session::read('member');
$id = md5($user['email']);
$document = Details::find('first', array('conditions' => array('user_id' => (string) $user['_id'])));
// if(count($document)==0){return $this->redirect('/');}
$uploadOk = 1;
if ($this->request->data) {
$extension = pathinfo($this->request->data['file']['name'], PATHINFO_EXTENSION);
$allowed = array('pdf');
if (!in_array(strtolower($extension), $allowed)) {
$msg = "Sorry, only PDF files are allowed.";
$uploadOk = 0;
}
if ($uploadOk = 1) {
$option = 'doc';
$data = array('details_' . $option . '_id' => (string) $document['_id'], 'docname' => $this->request->data['docname'], 'date' => $this->request->data['date'], 'DateTime' => new \MongoDate(), 'keywords' => $this->request->data['keywords'], 'description' => $this->request->data['description'], $option => $this->request->data['file'], $option . '.verified' => 'No', $option . '.IP' => $_SERVER['REMOTE_ADDR']);
$field = 'details_' . $option . '_id';
$Documents = Documents::create($data);
$saved = $Documents->save();
$fileData = array('file' => $this->request->data['file'], 'documents_' . $option . '_id' => (string) $Documents->_id);
$file = File::create();
if ($file->save($fileData)) {
$msg = "Upload OK";
}
$image_address = File::find('first', array('conditions' => array('documents_doc_id' => (string) $Documents->_id)));
if ($image_address['filename'] != "") {
$imagename_address = $image_address['_id'] . '_' . $image_address['filename'];
$path = LITHIUM_APP_PATH . '/webroot/download/' . $imagename_address;
file_put_contents($path, $image_address->file->getBytes());
}
// print_r($path);
$pages = $this->getPDFPages($path);
// Output: 13
// print_r($pages);exit;
unlink($path);
$docdata = array();
foreach ($pages as $page) {
$params = explode(":", $page);
$left = $params[0];
$right = $params[1];
$docdata = array_merge($docdata, array($left => trim($right)));
}
$data = array("document" => $docdata);
$conditions = array("_id" => (string) $Documents->_id);
Documents::update($data, $conditions);
// Use the function
}
}
return $this->redirect('ex::save');
}
示例15: load
public function load()
{
$this->populate(unserialize(Session::read('location')));
$lat = $this->point->getLat();
$lng = $this->point->getLng();
if (empty($lat) || empty($lng)) {
$city = new City();
$city->setName("São Paulo");
$city->setState("SP");
$this->point->setLat(-23.48033);
$this->point->setLng(-46.63459);
$this->address->setCity($city);
}
}