mirror of
https://github.com/filegator/filegator.git
synced 2025-10-23 23:36:05 +02:00
130 lines
5.9 KiB
HTML
130 lines
5.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<title></title>
|
|
|
|
<link rel="stylesheet" href="/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="/css/font-awesome.min.css">
|
|
<link rel="stylesheet" href="/css/highlight.dark.css">
|
|
<link rel="stylesheet" href="/css/main.css">
|
|
</head>
|
|
<body>
|
|
|
|
<header class="navbar navbar-default navbar-fixed-top">
|
|
|
|
<a class="navbar-brand" href="/">
|
|
The title
|
|
<small class="hidden-xs hidden-sm">
|
|
This is the default subtitle!
|
|
</small>
|
|
</a>
|
|
|
|
|
|
</header>
|
|
|
|
<main class="container">
|
|
<div class="row">
|
|
|
|
|
|
<section id="content" class="col-sm-12">
|
|
<h2 id="default-session-handler">Default Session handler</h2>
|
|
<p>Session handling is provided through the Symfony's <a href="https://symfony.com/doc/4.4/components/http_foundation.html">HttpFoundation</a> component. Please check their docs for more info.</p>
|
|
<p>Default session handler will user PHP's built in file storage. You can also specify your own <code>$save_path</code> to store session files.</p>
|
|
<pre><code> 'Filegator\Services\Session\SessionStorageInterface' => [
|
|
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
|
'config' => [
|
|
'handler' => function () {
|
|
$save_path = null; // use default system path
|
|
//$save_path = __DIR__.'/private/sessions';
|
|
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler($save_path);
|
|
|
|
return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([], $handler);
|
|
},
|
|
],
|
|
],</code></pre>
|
|
<h2 id="configuring-session-service-to-use-database">Configuring Session service to use database</h2>
|
|
<p>First, create a table <code>sessions</code> with this sql:</p>
|
|
<pre><code>CREATE TABLE `sessions` (
|
|
`sess_id` varbinary(128) NOT NULL,
|
|
`sess_data` blob NOT NULL,
|
|
`sess_lifetime` mediumint(9) NOT NULL,
|
|
`sess_time` int(10) unsigned NOT NULL,
|
|
PRIMARY KEY (`sess_id`)
|
|
) CHARSET=utf8 COLLATE=utf8_bin;</code></pre>
|
|
<p>Then, open <code>configuration.php</code> and update Session handler to:</p>
|
|
<pre><code> 'Filegator\Services\Session\SessionStorageInterface' => [
|
|
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
|
'config' => [
|
|
'handler' => function () {
|
|
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler(
|
|
'mysql://root:password@localhost:3306/filegator'
|
|
);
|
|
|
|
return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([], $handler);
|
|
},
|
|
],
|
|
],
|
|
</code></pre>
|
|
<p>Don't forget to enter correct database details.</p>
|
|
<h2 id="configuring-session-service-to-use-redis">Configuring Session service to use Redis</h2>
|
|
<p>You must require additional <a href="https://github.com/nrk/predis/">predis</a> library <code>composer require predis/predis</code></p>
|
|
<pre><code> 'Filegator\Services\Session\SessionStorageInterface' => [
|
|
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
|
'config' => [
|
|
'handler' => function () {
|
|
$predis = new \Predis\Client('tcp://127.0.0.1:6379');
|
|
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler($predis);
|
|
|
|
return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([], $handler);
|
|
},
|
|
],
|
|
],</code></pre>
|
|
<h2 id="tweaking-session-options">Tweaking session options</h2>
|
|
<p>The underying <a href="https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php">session component</a> accepts array of options.
|
|
For example you can pass <code>cookie_lifetime</code> parameter to extend default session lifetime:</p>
|
|
<pre><code> 'Filegator\Services\Session\SessionStorageInterface' => [
|
|
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
|
'config' => [
|
|
'handler' => function () {
|
|
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler(
|
|
'mysql://root:password@localhost:3306/filegator'
|
|
);
|
|
|
|
return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([
|
|
'cookie_lifetime' => 365 * 24 * 60 * 60, // one year
|
|
], $handler);
|
|
},
|
|
],
|
|
],
|
|
</code></pre>
|
|
</section>
|
|
|
|
</div>
|
|
</main>
|
|
|
|
<footer>
|
|
<div class="container">
|
|
<p class="text-muted">
|
|
website generated with <a href="http://couscous.io" title="Markdown website generator">Couscous</a>
|
|
</p>
|
|
</div>
|
|
</footer>
|
|
|
|
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
|
|
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
|
|
<script src="//yastatic.net/highlightjs/8.2/highlight.min.js"></script>
|
|
|
|
<script>
|
|
$(function() {
|
|
$("section>h1").wrap('<div class="page-header" />');
|
|
// Syntax highlighting
|
|
hljs.initHighlightingOnLoad();
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|