Session initialization in DB

48 views
Skip to first unread message

Roman

unread,
Apr 3, 2022, 2:57:45 AM4/3/22
to Fat-Free Framework
While debugging I noticed that every time I access app, this command invokes:

CREATE TABLE IF NOT EXISTS `database`.`sessions` (    `session_id` VARCHAR(255),    `data` TEXT,    `ip` VARCHAR(45),    `agent` VARCHAR(300),    `stamp` INTEGER,    PRIMARY KEY (`session_id`) );

I believe this is invoked by this action:

$session = new \DB\SQL\Session($db);

My question: Is it optimal to call such SQL queries on each application load? How to turn off such check? I know I have this table in DB and if not - I would like to see error, but not "auto create".

Paul Herring

unread,
Apr 3, 2022, 6:33:35 AM4/3/22
to Roman per Fat-Free Framework
> How to turn off such check?


"A 3rd parameter is used to $force the table creation, if it's not existing."

e.g. in my code:

if (!isset($_SESSION)) {

    $session = new \DB\SQL\Session(
        $f3->get('DB'),
        'sessions',
        false /* DB should be created using the update scripts, so no TRUE here */,
        null,
        'CSRF'
    );
} else {
    // Only expecting this bit if the database has been updated in sanityCheck(),
    // which is needed before we attempt to store the session there.
    //
    // php7.2 generates a 'Cannot change session name when session is active' error otherwise
}


--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to the Google Groups "Fat-Free Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to f3-framework...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/23d76152-af62-49de-b435-70c52e1bc822n%40googlegroups.com.


--
PJH

Reply all
Reply to author
Forward
0 new messages