Jump to content
  • Advertisement
Sign in to follow this  
jumpjumpjump

[web] Getting last visit time for custom forum script

This topic is 4776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having serious issues trying to figure out how to do this. I have the timestamp updated in the user's row in the db each page load. With the following code:
		$time = time();
		$sql = "UPDATE `os_users` SET `user_lastlogin` = '". $time ."' WHERE `user_id`= '".$db->escape_string($_SESSION['user_id'])."' LIMIT 1";
		$result = $db->query($sql);

Now what do I need to do from there to get the last time they visited?

Share this post


Link to post
Share on other sites
Advertisement
You mean this?
"SELECT `user_lastlogin` FROM `os_users` WHERE `user_id`= ".$db->escape_string($_SESSION['user_id'])."' LIMIT 1"

Share this post


Link to post
Share on other sites
...I suggest you fish through the phpbb code, there is no truely efficient way of doing this, as far as i've seen, unless you can rig up a session array(huge strain on server though)

Share this post


Link to post
Share on other sites
This might sound a bit lame, but why are updating last_login every page view? Visitors don't login again every single page.
I would suggest you use two fields: last_login and last_pageview. Or save their session id to see if they been away for a while (not the most precise method ofcourse).

Share this post


Link to post
Share on other sites
In your login script, set a session varible to the lastlogin time, before you update the database.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!