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

Fatal error: Call to undefined method Phalcon\Session\Adapter\Database::session_id()

Fatal error: Call to undefined method Phalcon\Session\Adapter\Database::session_id() in /mnt/www/web/public/index.php

My code:

$connection = new \Phalcon\Db\Adapter\Pdo\Mysql(array(
    "host" => "localhost",
    "username" => "root",
    "password" => "xxx",
    "dbname" => "xxx"
));

$session = new \Phalcon\Session\Adapter\Database(array(
    'db' => $connection,
    'table' => 'session_data_phal'
));

if (isset($_GET['setsid'])) {
    $session->session_id($_GET['setsid']);
}

$session->start();

Is a bug or im doing something wrong?



98.9k

There's no method called session_id in \Phalcon\Session\Adapter\Database in as you can see https://github.com/phalcon/incubator/blob/master/Library/Phalcon/Session/Adapter/Database.php



3.2k

Any idea to set a session id? Is there a way?



3.2k
edited Jul '14

When I use the native php it works:

if(isset($_GET['setsid']))
{
    session_id($_GET['setsid']);
}

But is not get registered. As soon i remove the ?setsid=mysession it returns to old session.



98.9k

You can use the PHP's function session_id or call setId before calling start:

$session->setId("myId");


3.2k

Sorry i made a mistake. In my first post what i wanted to say is that the function setId() does not work when use $session->setId("myId");

Fatal error: Call to undefined method Phalcon\Session\Adapter\Database::setId()

Anyway i fixed with native session_id(). Suddenly started to work again.

Thanks.