David JorHpan David JorHpan - 1 month ago 18
PHP Question

Deleting current unique session id by phalcon?

When I logout from

cop1
app (project), if I used
$this->session->destroy
:it is destroyed all two app sessions (two apps are logout), but if I used
remove
function it working well eg.
$this->session->remove("user")
.Because its only destroyed relative session user thus only
cop1
is logout. My needing one is deleting all current(cop1) sessions not only session variable
user
? How can I handle this ?

localhost/cop1/..

$di->set('session', function () {
$session = new SessionAdapter();
$session->setOptions(['uniqueId'=> "cop1_"]);
$session->start();
return $session;
});


localhost/cop2/..

$di->set('session', function () {
$session = new SessionAdapter();
$session->setOptions(['uniqueId'=> "cop2_"]);
$session->start();
return $session;
});

Answer

I can't try with session bag because my current project has so many modules and sessions ,so I have no time for replacing codes . Now my problem is solved by session_name but I don't know is it a good one ? Hoping helpful for some like me ...

session_name lets you give each application [same domain] a different session.

localhost/cop1/..

$di->set('session', function () {
    $session = new SessionAdapter();
    $session->setOptions(['uniqueId'=> "cop1_"]);
    session_name("cop1");
    $session->start();    
    return $session;
});

localhost/cop2/..

$di->set('session', function () {
    $session = new SessionAdapter();
    $session->setOptions(['uniqueId'=> "cop2_"]);
    session_name("cop2");
    $session->start();    
    return $session;
});