Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sven0188's avatar

Laravel 5.4 Session Expires jQuery Post

Good day,

I have a js method that runs on an interval via setInterval(). The js script does a jQuery post method. This gets repeated until certain condition is met. I don't think all details are relevant to my problem.

So here is my issue - on my dev environment everything works 100%. But on production environment the jquery post hangs basically as the session times out and when I refresh page it takes me to login screen.

I have set the session interval in session.php in laravel.

What else can cause this session to expires? And why is it working on my dev environment but not production env? Using Laragon in both instances.

    function checkFile() {
      clearInterval(checkFileID);

      var url = "{{ route('scan.checkfile.post') }}";
      $.post(url, {"_token": "{{ csrf_token() }}" }, function(response) {
        if (response.success == null) {
          //Still waiting for file the be generated so just continue checking (PLC SLOW maybe :) )
          checkFileID = setInterval("checkFile()", 1000);

        }else if (response.success == true) {
          //All good go to scan page
          gotoScanPage();
        }else if(response.success == false) {
          $("div#wait").hide(500);

          modelline.val(response.modelline);
          ordernumber.val(response.ordernumber);
          supplygroup.val(response.supplygroup);
          
          $.each(response.message, function(key, value) {
              var failures = $("div#failures");
              failures.append("<div class='alert alert-danger'><strong>Failure:</strong> " + value);
          });

          $("div#page_header").hide(100);
          $("div#failures_main_div").show(500);
          $("div#form_override").show(500);
        }

      });
    }
0 likes
2 replies
Sven0188's avatar

Chrome:

POST http://localhost/camerax/public/wait/checkfile 401 (Unauthorized)
Sven0188's avatar
Sven0188
OP
Best Answer
Level 4

Okay my quick solution is the except the function from the Controller Middelware :)

1 like

Please or to participate in this conversation.