Welcome Guest, Not a member yet? Register   Sign In
Session File Handler
#1

Hello, I'm creating an API to upload a file and I'm having problems creating session. I've already changed the permissions of the folders under "writable" and "public" to 777 and changed their owner to www-data.Greatful. 

My .env file
app.sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler'
app.sessionCookieName = 'vulcan_session'
app.sessionExpiration = 7200
app.sessionSavePath = NULL
app.sessionMatchIP = false
app.sessionTimeToUpdate = 300
app.sessionRegenerateDestroy = false

security.tokenName = 'vulcan_token'
security.headerName = 'X-CSRF-TOKEN'
security.cookieName = 'vulcan_cookie'
security.expires = 7200
security.regenerate = true
security.redirect = true
security.samesite = 'Lax'

The error:
{
    "title": "ErrorException",
    "type": "ErrorException",
    "code": 500,
    "message": "mkdir(): Permission denied",
    "file": "/var/www/html/sistema/system/Session/Handlers/FileHandler.php",
    "line": 112,
    "trace": [
        {
            "function": "errorHandler",
            "class": "CodeIgniter\\Debug\\Exceptions",
            "type": "->"
        },
        {
            "file": "/var/www/html/sistema/system/Session/Handlers/FileHandler.php",
            "line": 112,
            "function": "mkdir"
        },
        {
            "function": "open",
            "class": "CodeIgniter\\Session\\Handlers\\FileHandler",
            "type": "->"
        },
        {
            "file": "/var/www/html/sistema/system/Session/Session.php",
            "line": 931,
            "function": "session_start"
        },
        {
            "file": "/var/www/html/sistema/system/Session/Session.php",
            "line": 245,
            "function": "startSession",
            "class": "CodeIgniter\\Session\\Session",
            "type": "->"
        },
        {
            "file": "/var/www/html/sistema/system/Config/Services.php",
            "line": 706,
            "function": "start",
            "class": "CodeIgniter\\Session\\Session",
            "type": "->"
        },
        {
            "file": "/var/www/html/sistema/system/Config/BaseService.php",
            "line": 256,
            "function": "session",
            "class": "CodeIgniter\\Config\\Services",
            "type": "::"
        },
        {
            "file": "/var/www/html/sistema/system/Config/BaseService.php",
            "line": 190,
            "function": "__callStatic",
            "class": "CodeIgniter\\Config\\BaseService",
            "type": "::"
        },
        {
            "file": "/var/www/html/sistema/system/Config/Services.php",
            "line": 692,
            "function": "getSharedInstance",
            "class": "CodeIgniter\\Config\\BaseService",
            "type": "::"
        },
        {
            "file": "/var/www/html/sistema/system/Config/BaseService.php",
            "line": 256,
            "function": "session",
            "class": "CodeIgniter\\Config\\Services",
            "type": "::"
        },
        {
            "file": "/var/www/html/sistema/system/HTTP/RedirectResponse.php",
            "line": 81,
            "function": "__callStatic",
            "class": "CodeIgniter\\Config\\BaseService",
            "type": "::"
        },
        {
            "file": "/var/www/html/sistema/system/Filters/CSRF.php",
            "line": 59,
            "function": "back",
            "class": "CodeIgniter\\HTTP\\RedirectResponse",
            "type": "->"
        },
        {
            "file": "/var/www/html/sistema/system/Filters/Filters.php",
            "line": 177,
            "function": "before",
            "class": "CodeIgniter\\Filters\\CSRF",
            "type": "->"
        },
        {
            "file": "/var/www/html/sistema/system/CodeIgniter.php",
            "line": 391,
            "function": "run",
            "class": "CodeIgniter\\Filters\\Filters",
            "type": "->"
        },
        {
            "file": "/var/www/html/sistema/system/CodeIgniter.php",
            "line": 324,
            "function": "handleRequest",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "/var/www/html/sistema/public/index.php",
            "line": 37,
            "function": "run",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        }
    ]
}
Reply
#2

Code:
app.sessionSavePath = NULL
Your session save path is null. You have to set the directory.

In fact, in Config/App.php it is already set to the default location in the writable folder:
PHP Code:
public $sessionSavePath WRITEPATH 'session'

Don't overwrite it in the .env file, or set the right path in the .env file, but it cannot be null.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

(07-09-2021, 09:25 AM)includebeer Wrote:
Code:
app.sessionSavePath = NULL
Your session save path is null. You have to set the directory.

In fact, in Config/App.php it is already set to the default location in the writable folder:
PHP Code:
public $sessionSavePath WRITEPATH 'session'

Don't overwrite it in the .env file, or set the right path in the .env file, but it cannot be null.

I've uncommented the line of PATH. It's works.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB