Skip to content

Commit

Permalink
afup#1415 Session in DB
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Jan 7, 2024
1 parent 82d4e55 commit 03e83d3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
6 changes: 6 additions & 0 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ services:
_defaults:
public: true

Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler:
public: false
arguments:
- 'mysql:host=%database_host%;port=%database_port%;dbname=%database_name%'
- { db_username: '%database_user%', db_password: '%database_password%' }

AppBundle\Controller\Event\:
resource: '../../sources/AppBundle/Controller/Event/*'
autowire: true
Expand Down
20 changes: 20 additions & 0 deletions db/migrations/20240106213200_sessions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

use Phinx\Migration\AbstractMigration;

class Sessions extends AbstractMigration
{
public function change()
{
$sql = <<<EOF
CREATE TABLE `sessions` (
`sess_id` VARBINARY(128) NOT NULL PRIMARY KEY,
`sess_data` BLOB NOT NULL,
`sess_lifetime` INTEGER UNSIGNED NOT NULL,
`sess_time` INTEGER UNSIGNED NOT NULL,
INDEX `sessions_sess_lifetime_idx` (`sess_lifetime`)
) COLLATE utf8mb4_bin, ENGINE = InnoDB;
EOF;
$this->execute($sql);
}
}
4 changes: 0 additions & 4 deletions htdocs/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

session_start();

/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require __DIR__.'/../vendor/autoload.php';
Debug::enable();
Expand All @@ -34,8 +32,6 @@
/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require __DIR__.'/../vendor/autoload.php';

session_start();

$kernel = new AppKernel('prod', false);
}

Expand Down
2 changes: 0 additions & 2 deletions htdocs/include/prepend.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Initialisation
ob_start();

session_start();

// Inclusion de l'autoload de composer
require_once dirname(__FILE__) . '/../../vendor/autoload.php';

Expand Down
4 changes: 0 additions & 4 deletions htdocs/pages/planete/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

session_start();

/** @var ClassLoader $loader */
$loader = require __DIR__.'/../../../vendor/autoload.php';
Debug::enable();
Expand All @@ -43,8 +41,6 @@
/** @var ClassLoader $loader */
$loader = require __DIR__.'/../../../vendor/autoload.php';

session_start();

$kernel = new PlaneteAppKernel('prod', false);
}

Expand Down
4 changes: 2 additions & 2 deletions planete/app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ framework:
default_locale: "%locale%"
trusted_hosts: ~
session:
storage_id: session.storage.php_bridge
handler_id: ~
# https://symfony.com/doc/4.x/session/database.html#store-sessions-in-a-relational-database-mariadb-mysql-postgresql
handler_id: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
fragments: ~
http_method_override: true
assets: ~
Expand Down

0 comments on commit 03e83d3

Please sign in to comment.