2019-12-09 18:44:56 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Core\Session;
|
|
|
|
|
|
|
|
use Friendica\App;
|
|
|
|
use Friendica\Model\User\Cookie;
|
2019-12-11 14:30:31 -05:00
|
|
|
use SessionHandlerInterface;
|
2019-12-09 18:44:56 -05:00
|
|
|
|
2019-12-09 18:50:05 -05:00
|
|
|
/**
|
2019-12-11 14:30:31 -05:00
|
|
|
* The native Session class which uses the PHP internal Session functions
|
2019-12-09 18:50:05 -05:00
|
|
|
*/
|
2019-12-11 14:30:31 -05:00
|
|
|
final class Native extends AbstractSession implements ISession
|
2019-12-09 18:44:56 -05:00
|
|
|
{
|
2019-12-28 18:03:58 -05:00
|
|
|
public function __construct(App\BaseURL $baseURL, SessionHandlerInterface $handler = null)
|
2019-12-09 18:44:56 -05:00
|
|
|
{
|
|
|
|
ini_set('session.gc_probability', 50);
|
|
|
|
ini_set('session.use_only_cookies', 1);
|
2019-12-11 14:30:31 -05:00
|
|
|
ini_set('session.cookie_httponly', (int)Cookie::HTTPONLY);
|
2019-12-09 18:44:56 -05:00
|
|
|
|
2019-12-11 14:30:31 -05:00
|
|
|
if ($baseURL->getSSLPolicy() == App\BaseURL::SSL_POLICY_FULL) {
|
2019-12-09 18:44:56 -05:00
|
|
|
ini_set('session.cookie_secure', 1);
|
|
|
|
}
|
|
|
|
|
2019-12-11 14:30:31 -05:00
|
|
|
if (isset($handler)) {
|
|
|
|
session_set_save_handler($handler);
|
|
|
|
}
|
2019-12-09 18:44:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function start()
|
|
|
|
{
|
|
|
|
session_start();
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|