Slim Framework does not recognize the saved sessions

Asked

Viewed 89 times

0

Guys, my directory in the slim framework was default..

/public
/vendor
/src
/cache
/app

among other folders..
and within the /public A index.php was calling the other files and folder normally..

require __DIR__ . '/../vendor/autoload.php';
if(empty(session_id()))
{
    session_start();
}
// Instantiate the app
$settings = require __DIR__ . '/../src/settings.php';
$app = new \Slim\App($settings);
// Set up dependencies
require __DIR__ . '/../src/dependencies.php';
// Register middleware
require __DIR__ . '/../src/middleware.php';
// Register routes
require __DIR__ . '/../src/routes.php';
// Run app
$app->run();

However I had to move these main folders to a subfolder /v1
getting directory only

/public
/v1

and with index.php dendo of /public certainly altered..

    require __DIR__ . '/../v1/vendor/autoload.php';
if(empty(session_id()))
{
    session_start();
}
// Instantiate the app
$settings = require __DIR__ . '/../v1/src/settings.php';
$app = new \Slim\App($settings);
// Set up dependencies
require __DIR__ . '/../v1/src/dependencies.php';
// Register middleware
require __DIR__ . '/../v1/src/middleware.php';
// Register routes
require __DIR__ . '/../v1/src/routes.php';
// Run app
$app->run();

Everything is working except the $_SESSION recorded it builds in the AuthModel.php normally but when arriving at the RestrictedController.php are all empty..


Yes I already checked if there are any errors in these files, but not because when the default directory was ok..

But unfortunately I need to use this last directory template said..
Someone can give me a light there that I no longer know where else I look for mistakes kkk (msm tvz being in the simplest place)

  • 1

    If the problem is really in session checking you can use the session_status() to check if the session is active. Take a look at documentation. Anyway, edit the question and be a little more specific too, this difficult to understand your problem.

  • Then boy, to be blunt.. I just put the slim folders inside the v1 folder directed to index.php to get the slim folders inside v1 , and then stopped recording the session.. It really is active in all directories.. but it is simply not recording

  • 1

    Take a look at the answer of this question.

  • That’s right the problem was in the session directory, because as I changed the project root directory was not locating the folder path /tmp ai changed using the settings described in the answer of the question ini_set('session.save_path', dirname(dirname(__FILE__)).'/v1/tmp') and it all worked out! Thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.