Session in modules

Hy!

I am writing a module where I would need some things to save in the session.
I am using normal PHP session variable ($_SESSION[“mymodule.something”]). The thing saves in the session temporary. When I refresh the page, data that I saved with this variable is gone. (null)
Is OXID preventing to save your own data to own session variable?


var_dump($_SESSION["module.sessionData"]);
$_SESSION["module.sessionData"] = $data;
var_dump($_SESSION["module.sessionData"]);

When I refresh the page, the output of first var_dump is always null.

I am working in constructor. And parent class doesn’t have it.

Now i also tried with OXID’s oxSession class and it stil don’t work.


$sess = oxSession::getVariable("asd");
var_dump($sess);
oxSession::setVariable("asd", "qwe");
$sess = oxSession::getVariable("asd");
var_dump($sess);die();

Thank you!

Probably there is no session started yet. You can use blForceSessionStart in config.inc.php to force a session.

Can I start that from module perhaps?
Because I don’t want to touch root config file.
Otherwise it works after that. :slight_smile: But I want to turn that on in module if it’s possible.

I think you could override oxsession::_forceSessionStart and replace “$this->getConfig()->getConfigParam(‘blForceSessionStart’)” with “true”.

Yes it’s working.
Thank you very much!