#2138 - "Your last visit:" time and date do not seem to be updating properly
| Identifier | #2138 |
|---|---|
| Issue type | Minor issue (breaks specific functionality) |
| Title | "Your last visit:" time and date do not seem to be updating properly |
| Status | Closed (no changes needed) |
| Handling member | Chris Graham |
| Addon | General / Uncategorised |
| Description | Hi,
On vwgolfmk1.org.uk some of our users have noticed that the time and date does not reflect their last visit time. I have just done some checks myself: I last visited the site at 1:51 PM (1) On my Mac browser it says - Your last visit: 14 January 2016, 8:44 AM (2) On my iPhone it says - Your last visit: Yesterday, 7:23 PM Looking in the database, m_last_visit_time for me (lhasadreams) shows 1453125116 or converted - GMT: Mon, 18 Jan 2016 13:51:56 GMT The other reporters are using a variety of browsers and OS's and all see the same. When does the Account Details/Search Block above the forum get updated ? Where does it get updated from ? Cheers Ade |
| Steps to reproduce | |
| Funded? | No |
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".


Comments
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.