User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,515 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,726 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 442 | Replies: 3
Reply
Join Date: Jun 2007
Posts: 71
Reputation: Pro2000 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Pro2000's Avatar
Pro2000 Pro2000 is offline Offline
Junior Poster in Training

Question Help with Last Activity Time

  #1  
Sep 27th, 2007
Peace, I wrote a PHP File Contains a login form, If the user logs in a field will be inserted into the MySQL DataBase, So I want to make an automatic logout after 20 minutes idle.
I wrote:
<?php
session_start();
require("Connecting_Config.php");
$unm=$_SESSION['user_name'];
$current_date=date("i"); //Only Minutes
$gt_lastactivity="select * from logs where Name='$unm'";
$do_gt_lastactivity=mysql_query($gt_lastactivity,$connect);
$arr=mysql_fetch_array($do_gt_lastactivity);
$last_activity_date=$arr['Last_Activity'];
$yyy=$current_date-$last_activity;
if ($yyy>20)
{
          Logout();
}
?>
I tried that and I encountered an error which does a logout to the user if he starts another hour.. Ex: Last_Activity= 59th Minute If he does a refresh in the 1st minute in the next hour it will logout, Who knows how to do that?
The great scientist see his web-site:
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: Help with Last Activity Time

  #2  
Sep 27th, 2007
try cookies. that might help you. this example from O'Reilly's Learning PHP5 (free: chapter 8)


// The cookie expires one hour from now
setcookie('short-userid','ralph',time( ) + 60*60);
// The cookie expires one day from now
setcookie('longer-userid','ralph',time( ) + 60*60*24);
// The cookie expires at noon on October 1, 2006
setcookie('much-longer-userid','ralph',mktime(12,0,0,10,1,2006));
Reply With Quote  
Join Date: Jun 2007
Posts: 71
Reputation: Pro2000 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Pro2000's Avatar
Pro2000 Pro2000 is offline Offline
Junior Poster in Training

Re: Help with Last Activity Time

  #3  
Sep 27th, 2007
try cookies. that might help you.
Sorry but I know this... I created a menu shows the available users, It gets the names from the mysql database, I need to make it when the user expires 20 minutes it will logout and delete the user name from the available users.
The great scientist see his web-site:
http://www.elnaggarzr.com/en
I'm sure that will be good for you!
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: Help with Last Activity Time

  #4  
Sep 27th, 2007
then you will check it with cookies again and if the given time is up, redirect the page the username from availables list.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:56 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC