Skip to content

request: storage of session info in database #18

@sylae

Description

@sylae

due to Reasons I'm Not Quite Sure About specific to my webserver setup, I can't really rely on php's default session handler (which just dumps sessions in, like, /var/php/sessions or some shit). Typically I've implemented a custom session handler which just stores the session data in the db which I'm using anyway, so it's nice and slick and cool.

However, doing this with Nin is Kind Of A Nightmare. I was able to get it working, but it required being slightly cursed:

    $cfg = array_merge($defaultConfig, require_once 'config.php');
    nf_config_initialize($cfg);
    nf_db_initialize();

    session_set_save_handler(new DatabaseSessionHandler(), true); // implements session interfaces to load/save a nin model
    session_start([
        // irrelevant cookie config snipped
    ]);

    nf_begin($cfg);

(full relevant code: wormrp/wormrp.com@41b8a68)

It'd be nice if there was a builtin way to store sessions in the database, or barring that, deferring the internal session_start until the database connection is spun up (realistically, on a modern website, i dont see much point in user session support if there's no database to connect to).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions