We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

[Solved] Where are Phalcon Session files (Adapter/Files) Stored?

Hi, i'm trying to use the default Session adapter of phalcon without success... i'm not unable to debug as the service initialization fail silently... anyway i get a Call to undefined method Phalcon\DI\Service::get()

when i try to get a session var via $this->di->session->get("myvar");

Any help?

PS. also, i've tried to investigate the C sources of phalcon diregtly on GitHub but i've not understood where exact implementation of functions are... For example in the Session Adapter i've found this line:

phalcon_session_start(TSRMLS_C);
https://github.com/phalcon/cphalcon/blob/master/ext/session/adapter.c#L114

where phalcon_session_start is implemented?

thanks.

I've solved partially. Now the session wok. The problem was the session service wasn't called from DI with di->get but with di->getService.

Anyway the questions are still valid:

  • where the session file is stored?
  • where are the implementations of the C methods called in the Phalcon .c sources?


98.9k
Accepted
answer
edited Oct '14

Phalcon\Session\Adapter\Files is just an object-oriented wrapper to the _SESSION super-global and some functions specified here: https://www.php.net/manual/en/book.session.php

phalcon_session_start is the same as session_start but without doing the function lookup in the PHP userland.

You can control where the sessions are stored using: https://www.php.net/manual/en/session.configuration.php#ini.session.save-path

Oh, ok, good to know! I thought you had your own implementation of sessions.

What about the second question? Just for future investigation and curiosity...

Thanks for the help!

OMG, i'm absolutely burnout... for today i should stop working.

Thanks very much for the help!

Hope this will help someonelse too.



8.1k
edited Oct '14

If you use linux, you can find your session files in /tmp. Like /tmp/sess_akdanfcrfc7dgpm7afbe82k952

Session works... set in DI

/**
         * Register session
         */
        $di->setShared('session', function() {
            $session = new \Phalcon\Session\Adapter\Files();
            $session->setoptions([
                'uniqueId' => 'privatRsc',
            ]);
            $session->start();
            return $session;
        });

and

$this->session->set("user-name", "Michael");

in one action, and read in other action

$user = $this->session->get('user-name');