Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session disappears after a few image requests #15551

Closed
frohlfing opened this issue Sep 21, 2016 · 3 comments
Closed

Session disappears after a few image requests #15551

frohlfing opened this issue Sep 21, 2016 · 3 comments

Comments

@frohlfing
Copy link

  • Laravel Version: 5.3.10
  • PHP Version: 5.6.25, Not Thread Safety
  • Session Driver: file
  • OS: SunOS 5.10 (Strato Webhosting) and XAMPP (Mac)

Description:

When I show a page with a few images and reload the page a few times, the session-data will be lost completely.

The problem happens on my production system (Linux), and on XAMP (Mac), too.

Steps To Reproduce:

The case can be simplified as follows:
Define this routes:

Route::get('dummyimage/{i}', function($i) {
    return '';
});

Route::group(['middleware' => 'auth'], function () {
    Route::get('killmysession', function() {
        print_r(Session::all());
        for ($i=0; $i < 500; $i++) {
            echo '<img src="' . url('dummyimage/' . $i) . '"/>';
        }
    });
});

If you call the url "./killmysession", sometimes your session will be killed.
When I load the images directly from file, all works fine.

Workaround:

I've written "session_start();" on the top of the route file. I know, it is not the final solution, but it works for me temporarily.

@GrahamCampbell
Copy link
Member

GrahamCampbell commented Sep 22, 2016

Doesn't look like a laravel bug, and your session start hack is really not a good idea. It also has nothing todo with laravel sessions.

@frohlfing
Copy link
Author

Sorry, don't believe this. If try it without laravel framework, and all works fine:

<?php

session_start();

if (isset($_GET['image'])) {
    echo '';
    exit;
}

print_r($_SESSION);

for ($i=0; $i < 500; $i++) {
    echo '<img src="http://localhost/test/kill_my_session.php?image=' . $i . '"/>';
}

Do you have an idea or a proposal what I can do?

@frohlfing
Copy link
Author

I can reproduce the issues on this system too:

  • Laravel Version: 5.1.33 (LTS)
  • PHP Version: 5.5.9
  • OS: Ubuntu 14.04

The problem is well know! I foundlaravel-locking-session.This package addresses the problem where session data will be lost due to concurrent requests. I have installed it now and it's seems to solve my problem - but I think this is a dirty solution.
What do you think about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants