User randomly getting logged out

I'm having an issue where I can log in as a user. But I will randomly get logged out.

I'm using the Galleriffic gallery jQuery plugin, and I think its only happening on those pages. But because it randomly happens, I'm having a hard time reproducing it predictably.

Its not due to time-out issue though, at least I don't think so. Because I can log in, and have to re-login within 15 seconds sometimes.

I guess it could be Galleriffic itself. But I actually think (but clearly don't know) that it may be a request taking to long type of a thing.

I'm using gallerific to serve thousands of pictures. But I break it up into slq Limits of 500 or less. Then it only displays about 20 at a time, but gallerific tries to pre-cache images.

Sometimes, those ajax requests go for a long time, and a LOT at the same time. I'm wondering if laravel gets too many Get requests from gallerific, or they are taking too long???

Nothing shows up in the logs. And I really have no idea how to track this issue down.

My images are all stored out of root, and I use a call to a controller 'getProtectedFile' to return the image. In firebug I can see the GET requests pile up when this happens. They all come back with 200 OK. Then, on the times I get logged out, after a few hundred 200 OK responses, I get two 302 Found responses for the ajax to 'getProtectedFile'. The very next request after the 302 is now to the Login page.

So it seems that suddenly I get redirected but I have no idea why.

Anyone have any ideas on how to figure this out?

Because I feel like I should post some sort of code, here is my getProtectedFiles function. Maybe I've got something wrong in here.

   public function getProtectedFile() {
      $size = \Input::get('size');
      $fileID = \Input::get('fileID');

      $downloadPdf = \Input::get('downloadPdf');
      $downloadName = \Input::get('downloadName') . ".pdf";


      if ($downloadPdf == 1) {
         $size = 'original';

         if (!$downloadName) {
            $downloadName = "file_download.pdf";
         }   

      }   

      $file = ppFiles::find($fileID);

      // Get thumbnails
      switch ($size) {
         case "original":
            $path =    "/" . $file->file_root_dir . $file->file_work_dir . $file->file_name . $file->file_ext;
            break;
         case "thumbTiny":
            $path =    "/" . $file->file_root_dir . $file->file_work_dir . "thumbs/tiny/"  . $file->file_name . "_25x25"   . $file->file_ext;
            break;
         case "thumbSmall":
            $path =    "/" . $file->file_root_dir . $file->file_work_dir . "thumbs/small/"  . $file->file_name . "_75x75"   . $file->file_ext;
            break;
         case "thumbMedium":
            $path =    "/" . $file->file_root_dir . $file->file_work_dir . "thumbs/medium/" . $file->file_name . "_125x125" . $file->file_ext;
            break;
         case "thumbLarge":
            $path =    "/" . $file->file_root_dir . $file->file_work_dir . "thumbs/large/"  . $file->file_name . "_200x200" . $file->file_ext;
            break;
         case "thumbHuge":
            $path =    "/" . $file->file_root_dir . $file->file_work_dir . "thumbs/huge/"  . $file->file_name . "_300x300" . $file->file_ext;
            break;

      }   


      if ($downloadPdf == 1) {
         $headers = array( 'Content-Type: application/pdf' );
         return \Response::download($path, $downloadName, $headers, 'attachment');
      }   

      $headers = array( 'Content-Type: image/jpeg' );
      return \Response::download($path, 'Test', $headers, 'inline');

   }   

I should probably add I'm using default setups right now for sessions. So file-based sessions.

Nertskull
Nertskull
  • 2 years ago

Probably not the issue, but might be worth checking php can write to the folder where sessions are stored if this is a development machine

elite123 said:

Probably not the issue, but might be worth checking php can write to the folder where sessions are stored if this is a development machine

Yeah the folder is all 777, and it is writing session files for multiple people logging in. And login authentication works most of the time across most pages.

So I doubt that is it, unless I'm missing something.

Check this:
http://stackoverflow.com/questions/24053235/laravel-auth-session-losing-when-redirect-pages

Was a solution ever discovered for this? I have the same type of scenario going on.