cancerian
Posts: 9
|
| Posted: 03/20/2010, 8:24 AM |
|
Hello -
I am using Authentication builder in CodeCharge. Everything works fine, except I can't figure out the way to implement inactivity timeout i.e. after a user has logged in , the session stays logs in until browser is closed (or user logs out). The site is hosted somewhere else , so I am not sure I have control over PHI.ini.
Is there a good way to implement inactivity timeout un CodeCharge or implement an action/code (using PHP) to do so ?
Any help/pointers are appreciated.
Thanks
|
 |
 |
feha
Posts: 712
|
| Posted: 03/20/2010, 1:08 PM |
|
I don't think it is possible.
You need to do it in php.ini or use session php functions ...
Other way would be using sessions management with MySQL ... a custom coded solution.
_________________
Regards
feha
www.vision.to
feedpixel.com |
 |
 |
laneoc
Posts: 154
|
| Posted: 03/20/2010, 1:35 PM |
|
The two means of which I am aware: web server settings (Apache for me), and/or javascript.
The web server settings are the quickest to put together.
The javascript way involves setting a timer which runs in the browser, then executing whatever code you choose when the timer goes off.
My approach is a combo: I set the web server settings as needed, then do the following in javascript to warn the user that the session is about to expire:
<script language="Javascript">
function ShowHello()
{
window.alert("If you are updating information on this page, please save it regularly to prevent losing it due to a timeout.");
setTimeout('ShowHello()', 900000);
}
setTimeout('ShowHello()', 900000);
</script>
When the page is loaded, the timer resets. If the timer expires, the user is prompted to (after clicking Okay on the alert popup) save the data on the page.
Hope this helps.
_________________
Lane |
 |
 |
melvyn
Posts: 333
|
| Posted: 03/20/2010, 9:14 PM |
|
I had that issue before and was easy to solve, since I record last login and last action done (I always keep an history of what user is doing).
Now hands to work:
Go to Common.php and insert code in the very first line, after <?php and before the includes; press enter twice in order to get 2 blank lines.
$last_action = $_SESSION['LAST_ACTION'];
$last_action + 900 < time() ? CCLogoutUser() : $_SESSION['LAST_ACTION'] = time();
In the line 1 we read when was the last action. If nothing is registered we'll a blank value.
In the line 2 we check how much time have happened since that last action. If more than 900 seconds (15 minutes), then logout, if not then set the last action to current time.
Why in the first line of common? Because this will always execute.
Whay 900? 15 * 60 = 900 -> seconds since last action.
The two above lines can be elaborated more and get more functionality.
Enjoy.
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com |
 |
 |
feha
Posts: 712
|
| Posted: 03/21/2010, 4:11 PM |
|
Great solution melvyn
_________________
Regards
feha
www.vision.to
feedpixel.com |
 |
 |
jouli
Posts: 1
|
| Posted: 04/20/2010, 2:43 AM |
|
so good and interesting I like it so much.
_________________
jouli |
 |
 |
mamboBROWN
Posts: 1713
|
| Posted: 04/20/2010, 6:30 PM |
|
cancerian
If melvyn's answer solved your question then please put [Resolved] or [Solved] in the thread title. Thanks.
|
 |
 |
cancerian
Posts: 9
|
| Posted: 04/27/2010, 6:53 PM |
|
Melvyn -
you mentioned that you keep track of what user is doing, I am assuming that is why your timeout logic in common.php is working..is that correct?
Can you please help me with the basic steps on how I can keep track of what user is doing and therefore can use the timeout code you sent ?
Thanks
|
 |
 |
magus
Posts: 98
|
| Posted: 05/17/2010, 10:46 AM |
|
Hi Cancerian,
The code that Melvyn posted does not require additional user tracking code to work.
Melvyn's code should work just as he described.
It uses a "LASTACTION" Session variable to store the time when a logged in user calls a page. Session variables are something that php looks after for you, they are stored on the server and persist between page calls.
The code tests that "LASTACTION" Session varaible isn't more than 15 minutes old before generating a page.
If it is more than 15 minutes old it calls the CCLogoutUser() function that logs out the user before giving any other response to the page call.
Regards,
Don A
|
 |
 |