SeaFuzz
SeaFuzz

Reputation: 1237

laravel undefined index session

This has happened to me 3 times in the past. Now this time I really want to figure out what the problem is. The way I fixed it the last few times, was to walk away. When I came back after a few hours, everything worked as expected, until days later when it happened again. I was clicking through pages without updating any code, then all of a sudden everything comes to a grinding halt.

I am getting an Undefined index: driver error in /Illuminate/Session/SessionServiceProvider.php

There is nothing written in the Laravel log file. The php_errors.log file doesn't have any details and neither does the apache_error.log file. I'm completely stumped, as well as dead in the water. I've tried rewinding to previous commit versions to make sure I didn't break something. But same issue no mater how far back I go.

Below is what I am getting:

ErrorException Undefined index: driver open: /Users/website/laravel4/vendor/laravel/framework/src/Illuminate/Session/SessionServiceProvider.php

protected function registerSessionEvents()
{
    $config = $this->app['config']['session'];

    // The session needs to be started and closed, so we will register a before
    // and after events to do all stuff for us. This will manage the loading
    // the session "payloads", as well as writing them after each request.
    **if ( ! is_null($config['driver']))**
    {
$this->registerBootingEvent();  

Line 94 is highlighted, indicated by two asterisks in the code above. I am running Laravel version 4.0

I've also tried updating composer

composer.json contains:

{
"require": {
    "laravel/framework": "4.0.*"
},
"autoload": {
    "classmap": [
        "app/commands",
        "app/controllers",
        "app/models",
        "app/database/migrations",
        "app/database/seeds",
        "app/libraries",
        "app/tests/TestCase.php"
    ]
},
"scripts": {
    "post-update-cmd": "php artisan optimize"
},
"minimum-stability": "dev"
} 

I've also tried changing minimum-stability to "stable" and that didn't seem to do it either.

Any help in solving this mystery would be greatly appreciated.

Upvotes: 3

Views: 3604

Answers (1)

petercoles
petercoles

Reputation: 1822

Session handling went through some extensive cleanup between 4.0 and 4.1 (see https://github.com/laravel/framework/commit/e0fe79e398003e54d54f2626e1283e97209b7f50#diff-a5878ed0d054cbfc634bf582d41b1848 for specifics). Before the changes I used to see unpredictable and difficult to explain problems with sessions too.

If you're still using version 4.0 you're likely to be in the wrong side of that cleanup. So although it's a bit vague and fluffy, I'd recommend upgrading to 4.1 and seeing if the problem goes away.

Upvotes: 1

Related Questions