Jump to content

Session data lost, is that a bug?


Numbered

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

<?php
$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 ^_^)

a0b0d9ac56f287221b512d16606fd962.thumb.png.e019627b17516e159555d1bd175c4915.png

 

Thanks for your advice!

afde7-clip-70kb.png

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)

ade37-clip-12kb.png.6f376c3078f7d9bf81d8ccf67953f945.png

Without this hard check all is right.

Link to comment
Share on other sites

Archived

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

  • Recently Browsing   0 members

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