Question

Logging me out after some minutes

Posted November 7, 2021 102 views
Laravel

I have a problem, when I log in to an admin panel in my laravel project after 3 to 4 minutes it is logging me out, but on a local server its working very fine. my SESSION_LIFETIME = 525600 in my environmental variable. Please help me solve this issue, am using an APP, DATABASE and SPACE. no droplet

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hello,

It sounds like that you might be using files as the session driver, meaning that your sessions are stored in the App container itself. The problem with this is that every time the container gets redeployed you would lose all of the sessions.

What I could suggest is to change your Laravel sessions driver to either cookie or database so that the sessions are actually persisted even if there is a deployment or if you have multiple web components.

Let me know how it goes.
Best,
Bobby

  • yes that’s true am using SESSIONDRIVER as file…… but again when I want to change the SESSIONDRIVER from file to database, am getting an error saying, “forbidden”.

    • Hello,

      When using the database session driver, you will need to create a table to contain the session records.

      You can do that by running to following commands:

      php artisan session:table
      
      php artisan migrate
      

      For more information, you can take a look at the documentation here:

      https://laravel.com/docs/8.x/session#driver-prerequisites

      Best,
      Bobby

      • Still am having an error, saying “forbidden”. But I think I know the reason why its saying that, I will fix it and I will tell you what will be next.

        But I have another problem, please help me fix it, when I upload a file its generating an “id” instead of a real file name..

        here are my codes from the controller on the upload

        if ($request-> hasfile('music')){
                    $filenamewithext = $request->file('music')->getClientOriginalName();
                    $filename = pathinfo($filenamewithext,PATHINFO_FILENAME);
                    $extension = $request->file('music')->getClientOriginalExtension();
                    $filenametostore = '1_'.$filename.'_'.time().'.'.$extension;
                    $beat->music = $request->music->store('/beats', 'spaces', $filenametostore, 'public');
                }