]> git.mxchange.org Git - friendica.git/blob - src/Core/Session/Native.php
Merge pull request #7995 from annando/probe-hubzilla
[friendica.git] / src / Core / Session / Native.php
1 <?php
2
3 namespace Friendica\Core\Session;
4
5 use Friendica\App;
6 use Friendica\Model\User\Cookie;
7 use SessionHandlerInterface;
8
9 /**
10  * The native Session class which uses the PHP internal Session functions
11  */
12 final class Native extends AbstractSession implements ISession
13 {
14         public function __construct(App\BaseURL $baseURL, Cookie $cookie, SessionHandlerInterface $handler = null)
15         {
16                 parent::__construct($cookie);
17
18                 ini_set('session.gc_probability', 50);
19                 ini_set('session.use_only_cookies', 1);
20                 ini_set('session.cookie_httponly', (int)Cookie::HTTPONLY);
21
22                 if ($baseURL->getSSLPolicy() == App\BaseURL::SSL_POLICY_FULL) {
23                         ini_set('session.cookie_secure', 1);
24                 }
25
26                 if (isset($handler)) {
27                         session_set_save_handler($handler);
28                 }
29         }
30
31         /**
32          * {@inheritDoc}
33          */
34         public function start()
35         {
36                 session_start();
37                 return $this;
38         }
39 }