Jump to content

Session data lost, is that a bug?


Recommended Posts

Let's see in \IPS\Session\Front class. When we read session IPS do some needed stuff in the last part this method fill $this>data array per each param. One of this key is $item->data['data']. It will fill with an inline condition:

'data' => $session ? $session['data'] : '',

May be ok. But after this reading we calling write method, which should update some things. But it is not doing because first line checks this condition 

!isset( $this->data['data'] )

This condition will be false every time, because empty is exist. 

It never make a trouble when you use default IPS login handler or third party, oauth and something else. But it will reproduce if you start working with $this->data, $this->setMember(..) inside hook for \IPS\Session\Front. Then this data isn't store and you have a success logged in user with session, cookies, device and all, but without $this->data['data'] info in session and in database too. I'm sure first code quote shoud be 

'data' => $session ? $session['data'] : NULL,

With that we get a correct result

$content = '';
var_dump(!isset($content)); // return bool(false)

$content = null;
var_dump(!isset($content)); // return bool(true)

With that condition will work and store data param to database (or to redis in 4.3 ^_^)



Thanks for your advice!


Link to comment
Share on other sites

I was wrong. It's not a point of bug. Actually it's mine mistake. I did a sso file, where i create a hook to \IPS\Session\Front to the read method.

As that doc said 

I can call a parent:read and before that check $this->member->member_id and if it exist - just return $result of parent::read. It's wrong. In some case member_id can be present at cookie, but the returned data is empty. But this method should return string. So this is a place of my throwned errors.

The red underscode is source of my script down (actually it's right.. null is not a string..but)


Without this hard check all is right.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...