本文整理汇总了PHP中Session::start方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::start方法的具体用法?PHP Session::start怎么用?PHP Session::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session::start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
/**
* Do not call directly. Use Session::getNamespace().
*/
private function start()
{
if ($this->meta === FALSE) {
$this->session->start();
$this->data =& $_SESSION['__NF']['DATA'][$this->name];
$this->meta =& $_SESSION['__NF']['META'][$this->name];
}
}
示例2: prepareForTests
protected function prepareForTests()
{
parent::prepareForTests();
Route::enableFilters();
$this->current_realm = Config::get('app.url');
$user = User::where('identifier', '=', 'sebastian.marcet')->first();
$this->be($user);
Session::start();
$scope = $this->getScopes();
$this->client_id = 'Jiz87D8/Vcvr6fvQbH4HyNgwTlfSyQ3x.openstack.client';
$this->client_secret = 'ITc/6Y5N7kOtGKhg';
$params = array('client_id' => $this->client_id, 'redirect_uri' => 'https://www.test.com/oauth2', 'response_type' => OAuth2Protocol::OAuth2Protocol_ResponseType_Code, 'scope' => implode(' ', $scope), OAuth2Protocol::OAuth2Protocol_AccessType => OAuth2Protocol::OAuth2Protocol_AccessType_Offline);
Session::set("openid.authorization.response", IAuthService::AuthorizationResponse_AllowOnce);
$response = $this->action("POST", "OAuth2ProviderController@authorize", $params, array(), array(), array());
$status = $response->getStatusCode();
$url = $response->getTargetUrl();
$content = $response->getContent();
$comps = @parse_url($url);
$query = $comps['query'];
$output = array();
parse_str($query, $output);
$params = array('code' => $output['code'], 'redirect_uri' => 'https://www.test.com/oauth2', 'grant_type' => OAuth2Protocol::OAuth2Protocol_GrantType_AuthCode);
$response = $this->action("POST", "OAuth2ProviderController@token", $params, array(), array(), array("HTTP_Authorization" => " Basic " . base64_encode($this->client_id . ':' . $this->client_secret)));
$status = $response->getStatusCode();
$this->assertResponseStatus(200);
$content = $response->getContent();
$response = json_decode($content);
$access_token = $response->access_token;
$refresh_token = $response->refresh_token;
$this->access_token = $access_token;
}
示例3: admin_logged
public static function admin_logged()
{
Session::start();
if (Session::get('user') === null) {
Tools::redirect('/admin/login');
}
}
示例4: testDeleteDeveloper
public function testDeleteDeveloper()
{
Session::start();
$response = $this->call('DELETE', '/developer/2', ['_token' => csrf_token()]);
$this->assertEquals(302, $response->getStatusCode());
$this->notSeeInDatabase('companies', ['deleted_at' => null, 'id' => 1]);
}
示例5: setUp
public function setUp()
{
parent::setUp();
Session::start();
$this->app->instance('middleware.disable', true);
$this->mock = $this->mock('App\\Interfaces\\ProductInterface');
}
示例6: iqWrapper
static function iqWrapper($xml = false, $to = false, $type = false, $id = false)
{
$session = \Session::start();
$dom = new \DOMDocument('1.0', 'UTF-8');
$iq = $dom->createElementNS('jabber:client', 'iq');
$dom->appendChild($iq);
if ($to != false) {
$iq->setAttribute('to', $to);
}
if ($type != false) {
$iq->setAttribute('type', $type);
}
global $language;
if ($id == false) {
$id = $session->get('id');
}
$iq->setAttribute('id', $id);
if (isset($language)) {
$iq->setAttribute('xml:lang', $language);
}
if (isset($session->user)) {
$iq->setAttribute('from', $session->get('username') . '@' . $session->get('host') . '/' . $session->get('resource'));
}
if ($xml != false) {
if (is_string($xml)) {
$f = $dom->createDocumentFragment();
$f->appendXML($xml);
$iq->appendChild($f);
} else {
$xml = $dom->importNode($xml, true);
$iq->appendChild($xml);
}
}
return $dom->saveXML($dom->documentElement);
}
示例7: testSetExpiration
/**
* Test expiration of namespaces and namespace variables.
* @return void
*/
public function testSetExpiration()
{
// try to expire whole namespace
$s = $this->session->getNamespace('expire');
$s->a = 'apple';
$s->p = 'pear';
$s['o'] = 'orange';
$s->setExpiration('+ 5 seconds');
$this->session->close();
sleep(6);
$this->session->start();
$s = $this->session->getNamespace('expire');
$result = $this->serialize($s->getIterator());
$this->assertEquals('', $result, 'iteration over named Session namespace failed');
// try to expire only 1 of the keys
$s = $this->session->getNamespace('expireSingle');
$s->setExpiration(5, 'g');
$s->g = 'guava';
$s->p = 'plum';
$this->session->close();
sleep(6);
$this->session->start();
$s = $this->session->getNamespace('expireSingle');
$result = $this->serialize($s->getIterator());
$this->assertEquals('p=plum;', $result, 'iteration over named Session namespace failed');
}
示例8: resumeOrStartSession
/**
*
* Resumes a previous session, or starts a new one, and loads the segment.
*
* @return null
*
*/
protected function resumeOrStartSession()
{
if (!$this->resumeSession()) {
$this->session->start();
$this->load();
}
}
示例9: login
static function login($data)
{
if (!isset($data["username"])) {
return self::UM_NoUserError;
} else {
$u = false;
$logged = false;
//check nick and password
$u = self::loadUserByNickname($data["username"]);
// assumo che la password mi sia arrivata in chiaro attraverso una connessione sicura
if ($u !== false && $u->getPassword() == Filter::encodePassword($data["password"])) {
$logged = true;
}
if ($u === false) {
//check mail and password
$u = self::loadUserByMail($data["username"]);
// assumo che la password mi sia arrivata in chiaro attraverso una connessione sicura
if ($u !== false && $u->getPassword() == Filter::encodePassword($data["password"])) {
header("location: " . FileManager::appendToRootPath());
}
}
if ($u !== false) {
if ($logged) {
if (Session::start($u)) {
return true;
} else {
return self::UM_NoSessionError;
}
}
return self::UM_NoPasswordError;
}
return self::UM_NoUserError;
}
}
示例10: bootstrap
public function bootstrap()
{
$this->constant();
//加载服务配置项
$servers = (require __DIR__ . '/service.php');
$config = (require ROOT_PATH . '/system/config/service.php');
$servers['providers'] = array_merge($config['providers'], $servers['providers']);
$servers['facades'] = array_merge($config['facades'], $servers['facades']);
$this->servers = $servers;
//自动加载系统服务
Loader::register([$this, 'autoload']);
//绑定核心服务提供者
$this->bindServiceProvider();
//添加初始实例
$this->instance('App', $this);
//设置外观类APP属性
ServiceFacade::setFacadeApplication($this);
//启动服务
$this->boot();
//定义错误/异常处理
Error::bootstrap();
//命令行模式
IS_CLI and die(Cli::bootstrap());
//导入类库别名
Loader::addMap(c('app.alias'));
//自动加载文件
Loader::autoloadFile();
//开启会话
Session::start();
//执行全局中间件
Middleware::globals();
//解析路由
Route::dispatch();
}
示例11: setUp
public function setUp()
{
parent::setUp();
Artisan::call('migrate');
Artisan::call('db:seed');
Session::start();
}
示例12: setUp
/**
* set up start
*/
public function setUp()
{
parent::setUp();
Session::start();
// $this->mock = Mockery::mock('\App\Group');
$this->id_test = Module::all()->first()->id;
}
示例13: __construct
function __construct()
{
global $_G;
parent::__construct();
loadLib('Session');
Session::start(db(), "{$_G['db_prefix']}session");
}
示例14: testMinification
public function testMinification()
{
Session::start();
$response = $this->post('process', ['html' => '<p><!--This is a comment--></p>', '_token' => csrf_token()])->withoutMiddleware();
$this->assertResponseOk();
$this->assertJson('{"html": "<p></p>"}');
}
示例15: run
public static function run()
{
Connection::connect();
Session::start();
Router::run();
Connection::disconnect();
}