Hello Everyone,

I am banging my head since morning. please help me.. I am not so good at php..i am in learning phase...

My requirement was to generate a popup once you immediately login. windows.alert('please call') then the popup should come for every 2 hrs.

Even though you navigate to different pages on the site..This should still come..

I have started something like this:--
1. Calling this script on everypage.

<script type="text/javascript">

And the code in the script is

function alert_settimer(){
    if(time_stop > 0) {
         timer= setTimeout("alert_settimer(),window.focus();window.alert('Please call Originator');",time_stop )

It is able to give me a popup for every 2 hrs. But whenever the user reloads the page after 1 hr. The function is called again and the count starts from 0hrs again. OR for example if 20 mins already passed then if i am going to a new page then the function is called again and so the timer starts again.
I am not getting any idea how to restrict it calling every time. OR send that 1 hr again to the function so that it starts from there. I tried some thing like setting the value in a session variable and then starting the counter from that value. But i am not successful. Please help me in solving this...

7 Years
Discussion Span
Last Post by Fbody

If you know anything about sessions, try storing the current remaining time in the session. That will allow it to persist between pages. You will then have to check the value stored in the session to determine what you need to do next.


Ok.. that is a possibility. But i already tried that way and i have no idea how to set a session variables from javascript?? The timer stuff i am doing is thru javascript which is client side and session variables are at server side..

if u have more information on this can you send me a sample code or likn where i can referr? thanks in advance!!


At the start of page load, use the server-side code to generate then echo the JS statement(s) that would set and enforce the timer rules on the client.

Send the JS as part of the <head> so that the client reads what the setting(s) should be while it's rendering the new page. If done correctly, you could put the server-side part in a single include file to simplify maintenance of the script, and improve consistency.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.