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?



84.5k

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



1.7k

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



1.7k
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.



84.5k

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

$session->setId("myId");


1.7k

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.