last_visit not being set?
Posted: 02 September 2008 03:30 AM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  177
Joined  07-30-2008

problem: unable to get accurate time of last login for current visitor

ive tried to retrieve this information using several different methods:

{exp:timesince}<?php global $SESS; echo $SESS->userdata['last_visit']; ?>{/exp:timesince}

the above method gives me “4 hours 9 minutes ago”

{exp:timesince}{exp:member:custom_profile_data}{last_visit}{/exp:member:custom_profile_data}{/exp:timesince}

the above method gives me “38 years, 8 months ago “

{exp:timesince}{exp:member:custom_profile_data member_id=logged_in_member_id}{last_visit}{/exp:member:custom_profile_data}{/exp:timesince}

the above method gives me “38 years, 8 months ago”

{exp:timesince}{exp:member:custom_profile_data member_id=2}{last_visit}{/exp:member:custom_profile_data}{/exp:timesince}

the above method gives me “38 years, 8 months ago”

in all cases, ive just logged out and then logged back in again, so i expect the values of all four methods above to be something like “1 minute ago”. what’s wrong?

Profile
 
 
Posted: 02 September 2008 03:47 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15368
Joined  05-15-2004

I’d suggest to leave out the timesince plugin for testing purposes. It’s clear to me that your last three attempts get a result of zero or empty, and thus are evaluaated as UNIX timestamp “0”, which happens to be 1/1/1970 0:00—indeed 38 years and 8 months ago.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 02 September 2008 01:10 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  177
Joined  07-30-2008

timesince was just there to simplify the interpreting of the Unix timestamp.

without timesince, i get 1220366458 using method 1 above, and blank (ie nothing) for the other three methods.

so the questions now are:

1. why am i getting nothing out of last_visit? is this not the preferred method of determining the time a member last visited?

2. why does the PHP method yield me a time that doesn’t correspond to my last visit? (1220366458 is Tue, 02 Sep 2008 14:40:58 GMT, which is about 4.5 hours ago; i’ve logged out and back in several times in the last few minutes so i expected to see a time corresponding to NOW or thereabouts).

EDIT: also, note that the above timestamp (1220366458) is not changing. when i log out, log back in, load a few pages (to make sure some activity is recorded), log out, then log back in, i see the same timestamp.

Profile
 
 
Posted: 02 September 2008 02:48 PM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15368
Joined  05-15-2004

Are you using template caching? Also, why don’t you simply use something like

{last_visit format="%Y %m %d"}

... ? Please also note that last_visit always refers to the date when the user was last active on the site prior to the current session.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 03 September 2008 03:56 AM   [ Ignore ]   [ # 4 ]  
Lab Assistant
RankRank
Total Posts:  177
Joined  07-30-2008

template caching is OFF.

adding the date format to the last_visit tag was a good idea, it makes it return a value rather than a blank as it was doing.

however, im still not able to use it to display… the last visit.

it displays a time, but the time is neither the last visit, nor the visit before that, nor any visit i had, even accounting for server offset.

if i log out and log back in i see it is still attached to that same time.

can you verify that if i log in, load a few pages, then log out and log back in again that i should see the time of my previous visit, i.e. about a minute ago?

also… to short-cut this whole process, i am simply trying to display all comments added by other visitors since the current user was last logged in. is there a recommended / tested chunk of code for that, i’d appreciate someone pointing me in that direction…

Profile
 
 
Posted: 10 September 2008 10:45 AM   [ Ignore ]   [ # 5 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12381
Joined  04-29-2002

fogcity, I found a thread related to last_visit that might help:

Link

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 16 September 2008 03:31 PM   [ Ignore ]   [ # 6 ]  
Lab Assistant
RankRank
Total Posts:  177
Joined  07-30-2008

thanks for the link. that thread however seems to conclude only that it’s best to not use {last_visit}... and use {last_activity} instead.

the bummer there is, last_activity doesn’t work for my purpose—highlighting news items posted since the current user’s last visit.

since last_activity is updated when the current page loads, it’s always going to be set to “now” for the current user…

Profile
 
 
Posted: 17 September 2008 09:53 AM   [ Ignore ]   [ # 7 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23522
Joined  05-20-2002

I believe the best way to handle it is via a plugin and cookies- there was one here along the lines of what you want.  However, the link looks to be 404.  But- I know that approach is how I’d go for control over the time issue.

Make sense?

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 17 September 2008 12:47 PM   [ Ignore ]   [ # 8 ]  
Lab Assistant
RankRank
Total Posts:  177
Joined  07-30-2008

does make sense in theory, although my site’s main user logs in through three different machines - home, work, iphone.

so, using cookies, he would have three different takes on what has changed…

still wondering why there isn’t a reliable tag to know the time a particular user last loaded a page on the site, since the server is keeping track of that?

Profile
 
 
Posted: 06 October 2008 07:30 PM   [ Ignore ]   [ # 9 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32861
Joined  05-14-2004

fogcity, I’m sorry that this has not received a response.  Are you still having difficulties with this?  If so, are you running any third party modules or extensions?

Also, what version and build of EE are you on? I might have missed it above, but I don’t see it there. =)

 Signature 
Profile
MSG
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64912 Total Logged-in Users: 28
Total Topics: 81864 Total Anonymous Users: 17
Total Replies: 440101 Total Guests: 181
Total Posts: 521965    
Members ( View Memberlist )
Newest Members:  bjmohrAqua193Bios Elementmjpoteetguimogranwelshmrcfthenetmonkeybenekwhobutsb