]> git.mxchange.org Git - friendica.git/blob - src/Core/Session/Native.php
Merge pull request #8044 from annando/contact-adding
[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, SessionHandlerInterface $handler = null)
15         {
16                 ini_set('session.gc_probability', 50);
17                 ini_set('session.use_only_cookies', 1);
18                 ini_set('session.cookie_httponly', (int)Cookie::HTTPONLY);
19
20                 if ($baseURL->getSSLPolicy() == App\BaseURL::SSL_POLICY_FULL) {
21                         ini_set('session.cookie_secure', 1);
22                 }
23
24                 if (isset($handler)) {
25                         session_set_save_handler($handler);
26                 }
27         }
28
29         /**
30          * {@inheritDoc}
31          */
32         public function start()
33         {
34                 session_start();
35                 return $this;
36         }
37 }