本文整理汇总了PHP中Session::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::get方法的具体用法?PHP Session::get怎么用?PHP Session::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session::get方法的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>';
}
示例2: __construct
/**
* Returns an instance of this class
*
* @param Controller $controller
* @param string $name
*/
public function __construct($controller, $name)
{
$fields = new FieldList(array(new HiddenField('AuthenticationMethod', null, $this->authenticator_class)));
$actions = new FieldList(array(FormAction::create('redirectToRealMe', _t('RealMeLoginForm.LOGINBUTTON', 'LoginAction'))->setUseButtonTag(true)->setButtonContent('<span class="realme_button_padding">Login or register with RealMe<span class="realme_icon_new_window"></span> <span class="realme_icon_padlock"></span>')->setAttribute('class', 'realme_button')));
// Taken from MemberLoginForm
if (isset($_REQUEST['BackURL'])) {
$backURL = $_REQUEST['BackURL'];
} elseif (Session::get('BackURL')) {
$backURL = Session::get('BackURL');
}
if (isset($backURL)) {
// Ensure that $backURL isn't redirecting us back to login form or a RealMe authentication page
if (strpos($backURL, 'Security/login') === false && strpos($backURL, 'Security/realme') === false) {
$fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
}
}
// optionally include requirements {@see /realme/_config/config.yml}
if ($this->config()->include_jquery) {
Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
}
if ($this->config()->include_javascript) {
Requirements::javascript(REALME_MODULE_PATH . "/javascript/realme.js");
}
if ($this->config()->include_css) {
Requirements::css(REALME_MODULE_PATH . "/css/realme.css");
}
parent::__construct($controller, $name, $fields, $actions);
}
示例3: testGet
/**
* @covers $this->object->get
* @todo Implement testGet().
*/
public function testGet()
{
session_start();
$_SESSION['test'] = 'TEST';
$this->assertEquals($this->object->get('test'), 'TEST');
$this->assertEquals($this->object->get('bogus', false), false);
}
示例4: printError
function printError($error, Session $session)
{
if (isset($session->get("errors")[$error])) {
echo $session->get("errors")[$error];
} else {
echo "";
}
}
示例5: country
/**
* Change country
*
* @param string $country
*/
public function country($country)
{
if (in_array($country, Kohana::config('site.countries'))) {
if ($this->session->get('country') == $country) {
// Clear country if same as given
$this->session->delete('country');
} else {
// Set country
$this->session->set('country', $country);
}
}
url::back();
}
示例6: __construct
function __construct()
{
parent::__construct();
if (Session::get("logged_in")) {
header("Location: " . URL . "index");
}
}
示例7: __construct
public function __construct()
{
// Asset::add('jquery.dropdown.css', 'css/jquery.dropdown.css');
Asset::add('bootstrap', 'css/bootstrap.min.css');
Asset::add('bootstrap-responsive', 'css/bootstrap-responsive.css');
Asset::add('common', 'css/common.css');
// Asset::add('style', 'css/style.css');
Asset::add('fontawsome', 'css/fontawesome.css');
Asset::add('flickcss', 'css/flick/jquery-ui-1.10.2.custom.css');
Asset::add('jquery', 'js/jquery-1.9.1.js');
Asset::add('jquery-migrate-1.1.1.js', 'js/jquery-migrate-1.1.1.js');
Asset::add('bootstrap-js', 'js/bootstrap.js');
Asset::add('jqueryui', 'js/jquery-ui-1.10.2.custom.min.js');
Asset::add('jquery.tablesorter.js', 'js/jquery.tablesorter.js');
Asset::add('jquery.tablesorter.pager.js', 'js/jquery.tablesorter.pager.js');
// $files = glob("public/css/pikachoose/*.css", GLOB_BRACE);
// foreach($files as $file)
// {
// Asset::add($file, substr($file, 7));
// }
if (Session::has('id') && Auth::check()) {
$account = Account::find(Session::get('id'));
if ($account->admin == 1) {
Session::put('admin', '1');
} else {
Session::put('admin', '0');
}
if ($account->blocked == 1) {
Session::put('alert', "Your account has been banned. Please contact the admin for more details");
Session::forget('id');
Auth::logout();
} else {
}
}
}
示例8: comprobarErrores
/**
* Método que comprueba si existen errores en la sessión
* @return Boolean True = cuando no hay errores, False = cuando hay errores
*/
public static function comprobarErrores()
{
if (Session::get('feedback_negative')) {
return false;
}
return true;
}
示例9: MarketPlaceReviewForm
public function MarketPlaceReviewForm()
{
Requirements::javascript(Director::protocol() . "ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js");
Requirements::javascript(Director::protocol() . "ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.min.js");
Requirements::combine_files('marketplace_review_form.js', array("themes/openstack/javascript/jquery.validate.custom.methods.js", "marketplace/code/ui/frontend/js/star-rating.min.js", "marketplace/code/ui/frontend/js/marketplace.review.js"));
$css_files = array("marketplace/code/ui/frontend/css/star-rating.min.css", "marketplace/code/ui/frontend/css/marketplace-review.css");
foreach ($css_files as $css_file) {
Requirements::css($css_file);
}
$form = new MarketPlaceReviewForm($this, 'MarketPlaceReviewForm');
$data = Session::get("FormInfo.Form_MarketPlaceReviewForm.data");
$review = $this->review_repository->getReview($this->company_service_ID, Member::CurrentUserID());
if (is_array($data)) {
//get data from cache
$form->loadDataFrom($data);
} elseif ($review) {
// get submitted review
$form->loadDataFrom($review);
}
// Optional spam protection
if (class_exists('SpamProtectorManager')) {
SpamProtectorManager::update_form($form);
}
return $form;
}
示例10: post_login
public function post_login()
{
$errors = new Laravel\Messages();
$input = Input::get();
try {
$validator = new Services\Session\Login\Validator($input);
$validator->publish();
} catch (ValidateException $errors) {
return Redirect::to(URL::to_route('session.login'))->with_input()->with_errors($errors->get());
}
try {
$valid_login = Sentry::login(Input::get('email'), Input::get('password'), Input::get('remember-me'));
if ($valid_login) {
$url = null;
if (Session::has('pre_login_url')) {
$url = Session::get('pre_login_url');
Session::forget('pre_login_url');
} else {
$url = URL::to_route('dashboard.profile');
}
return Redirect::to($url);
} else {
$errors->add('errors', __('application.invalid_login'));
return Redirect::to(URL::to_route('session.login'))->with_input()->with_errors($errors);
}
} catch (Sentry\SentryException $e) {
$errors->add('errors', $e->getMessage());
return Redirect::to(URL::to_route('session.login'))->with_input()->with_errors($errors);
}
}
示例11: __construct
function __construct()
{
parent::__construct();
if (Session::get('user_login')) {
echo '<script type="text/javascript"> window.location.replace("' . URL . 'dashboard") </script>';
}
}
示例12: exeCheck
function exeCheck()
{
$id = Session::get('user')['id'];
$userId = (int) Request::post('userId');
$status = (int) Request::post('status');
if ($id > 0 && $userId > 0) {
$array = array();
switch ($status) {
case '-1':
if ($this->exeInsert($id, $userId) > 0) {
$array = array('status' => 1, 'text' => 'Đang gửi yêu cầu');
}
break;
case '0':
if ($this->exeHandling($userId, $id, 1) > 0) {
$array = array('status' => 2, 'text' => 'Bạn bè');
}
break;
case '1':
if ($this->exeDelete($userId, $id) > 0) {
$array = array('status' => -1, 'text' => 'Kết bạn');
}
break;
case '2':
if ($this->exeDelete($userId, $id) > 0) {
$array = array('status' => -1, 'text' => 'Kết bạn');
}
break;
}
echo json_encode($array);
} else {
exit;
}
}
示例13: init
/**
* Allow this controller to be viewed when the site is in draft mode.
*/
function init()
{
$draftsecurity = Session::get('unsecuredDraftSite');
Session::set("unsecuredDraftSite", true);
parent::init();
Session::set("unsecuredDraftSite", $draftsecurity);
}
示例14: putChangePassword
/**
* 动作:修改当前账号密码
* @return Response
*/
public function putChangePassword()
{
$response = array();
// 获取所有表单数据
$data = Input::all();
$admin = Session::get("admin");
// 验证旧密码
if (!Hash::check($data['password_old'], $admin->pwd)) {
$response['success'] = false;
$response['message'] = '原始密码错误';
return Response::json($response);
}
// 创建验证规则
$rules = array('password' => 'alpha_dash|between:6,16|confirmed');
// 自定义验证消息
$messages = array('password.alpha_dash' => '密码格式不正确。', 'password.between' => '密码长度请保持在:min到:max位之间。', 'password.confirmed' => '两次输入的密码不一致。');
// 开始验证
$validator = Validator::make($data, $rules, $messages);
if ($validator->passes()) {
// 验证成功
// 更新用户
$admin->pwd = Hash::make(Input::get('password'));
if ($admin->save()) {
$response['success'] = true;
$response['message'] = '密码修改成功';
} else {
$response['success'] = false;
$response['message'] = '密码修改失败';
}
} else {
$response['success'] = false;
$response['message'] = $validator->errors->first();
}
return Response::json($response);
}
示例15: get
public static function get($var)
{
if (!Session::has($var)) {
return false;
}
return Session::get($var);
}