I do agree. The clean solution would be moving it into the sessions table as a new field (#2141).
An easier, but sub-optimal, solution would be to check if the time in the cookie is more than the session expiry time, and consider that the same as it being unset (hence having it copy over).
I was about to give a code example, but I can see we already did it in a newer patch release!
sources/forum/cns.php...
Yours:
$lvt=$this->get_member_row_field($id,'m_last_visit_time');
if ((!array_key_exists('last_visit',$_COOKIE)) && ($GLOBALS['FORUM_DRIVER']->get_guest_id()!=$id))
Newest:
if (((!array_key_exists('last_visit',$_COOKIE)) || ($lvt<time()-60*60*12)) && ($GLOBALS['FORUM_DRIVER']->get_guest_id()!=$id))
(actually it hard-codes 12h rather than expiry time, but similar enough)
It got me thinking about unrelated issues with cookies (#2140).
Actually the code there isn't what I said. It's doing it a different way. It's seeing if the last hit in the DB is really old, which is another a of saying that the visit in the cookie might as well be that old value.
Valid approach also. Thinking about this does tie my head in knots a little TBH.
When a new session starts, the last visit (last hit, really) database time is copied to the session cookie.
A session cookie holds until the browser is closed.
So, if a browser is kept open, that visit is still open, and hence the prior visit to that persists as-was.
I closed my running browsers and the time all updated.
Happy new year to you btw.
This does feel odd though, especially with mobile devices where browsers remain open for what can be weeks or months.
Can the session cookie not be updated more often than the start of the visit ?
Cheers
Ade
I do agree. The clean solution would be moving it into the sessions table as a new field (#2141).
An easier, but sub-optimal, solution would be to check if the time in the cookie is more than the session expiry time, and consider that the same as it being unset (hence having it copy over).
I was about to give a code example, but I can see we already did it in a newer patch release!
sources/forum/cns.php...
Yours:
$lvt=$this->get_member_row_field($id,'m_last_visit_time');
if ((!array_key_exists('last_visit',$_COOKIE)) && ($GLOBALS['FORUM_DRIVER']->get_guest_id()!=$id))
Newest:
if (((!array_key_exists('last_visit',$_COOKIE)) || ($lvt<time()-60*60*12)) && ($GLOBALS['FORUM_DRIVER']->get_guest_id()!=$id))
(actually it hard-codes 12h rather than expiry time, but similar enough)
It got me thinking about unrelated issues with cookies (#2140).
Valid approach also. Thinking about this does tie my head in knots a little TBH.