How to keep PHP session during long upload

Asked

Viewed 63 times

2

Hello, I have a basic authentication system using Session for a file-upload system However, when some user with slow internet puts many files in the upload queue (10 or more files), and each file would take 1 hour to be uploaded, it ends up being disconnected after 1 or more hours

I have tried to solve this problem using the directives
Session.gc_maxlifetime
Session.cookie_lifetime

And also the function session_set_cookie_params.

However, even using them, the user continues to be dropped after 1 hour or a little more and can never complete the rest of his uploads
(Since the session is destroyed by inactivity on the page, although it keeps uploading the file)

1 answer

1


You can use session_cache_expire() it increases or decreases the expiration time of a session. Take as parameter the time in minutes for the session to expire. We need to declare this function before session_start(). See an example of this function:

<?php
//INICIO A SESSÃO COM UM TEMPO DE EXPIRAÇÃO DE 10 MINUTOS
session_cache_expire(10);
session_start();
?>

You can also use as alternative:

Create a Cookie where you have to use the Cookie to maintain, in case the Sesssions are deleted, then you search the cookies and restore the Sesssions.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.