Пример #1
0
 protected function registerOptions(Application $app)
 {
     $app['session.options'] = [];
     $app['session.options.import_from_ini'] = true;
     $app['session.options_bag'] = $app->share(function () use($app) {
         /*
          * This does two things.
          * 1) Merges options together. Precedence is as follows:
          *    - Options from session.options
          *    - Options from ini (if enabled with "session.options.import_from_ini")
          *    - Options hardcoded below
          * 2) Converts options to an OptionsBag instance
          */
         $defaults = ['save_handler' => 'files', 'save_path' => '/tmp', 'name' => 'PHPSESSID', 'lazy_write' => true, 'gc_probability' => 1, 'gc_divisor' => 1000, 'gc_maxlifetime' => 1440, 'cookie_lifetime' => 0, 'cookie_path' => '/', 'cookie_domain' => null, 'cookie_secure' => false, 'cookie_httponly' => false, 'restrict_realm' => false];
         $options = new OptionsBag($defaults);
         if ($app['session.options.import_from_ini']) {
             foreach ($options as $key => $value) {
                 $options[$key] = ini_get('session.' . $key);
             }
         }
         // @deprecated backwards compatibility:
         if (isset($app['session.storage.options'])) {
             $options->add($app['session.storage.options']);
         }
         // PHP's native C code accesses filesystem with different permissions than userland code.
         // If php.ini is using the default (files) handler, use ours instead to prevent this problem.
         if ($options->get('save_handler') === 'files') {
             $options->set('save_handler', 'filesystem');
             $options->set('save_path', 'cache://.sessions');
         }
         $options->add($app['session.options']);
         return $options;
     });
 }
Пример #2
0
 /**
  * Add options
  *
  * @param OptionsBag $options
  */
 public function setOptions(OptionsBag $options)
 {
     $this->options->add($options->all());
 }
Пример #3
0
 protected function registerOptions(Application $app)
 {
     $app['session.options'] = [];
     $app['session.options.import_from_ini'] = true;
     $app['session.options_bag'] = $app->share(function () use($app) {
         /*
          * This does two things.
          * 1) Merges options together. Precedence is as follows:
          *    - Options from session.options
          *    - Options from ini (if enabled with "session.options.import_from_ini")
          *    - Options hardcoded below
          * 2) Converts options to an OptionsBag instance
          */
         $defaults = ['save_handler' => 'files', 'save_path' => '/tmp', 'name' => 'PHPSESSID', 'lazy_write' => true, 'gc_probability' => 1, 'gc_divisor' => 1000, 'gc_maxlifetime' => 1440, 'cookie_lifetime' => 0, 'cookie_path' => '/', 'cookie_domain' => null, 'cookie_secure' => false, 'cookie_httponly' => false, 'restrict_realm' => false];
         $options = new OptionsBag($defaults);
         if ($app['session.options.import_from_ini']) {
             foreach ($options as $key => $value) {
                 $options[$key] = ini_get('session.' . $key);
             }
         }
         if (isset($app['session.storage.options'])) {
             $options->add($app['session.storage.options']);
         }
         $options->add($app['session.options']);
         return $options;
     });
 }