Jump to content

php session about to expire in "X" minutes warning script..


pavanpuligandla

Recommended Posts

hii..

 

i'm ending the session after 30 minutes of inactivity in my php page containing 3 frames using:

<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; CHARSET=UTF-8">
<META HTTP-EQUIV="CONTENT-SCRIPT-TYPE" CONTENT="text/javascript">
<META HTTP-EQUIV="CONTENT-STYLE-TYPE" CONTENT="text/css">

<META HTTP-EQUIV="EXPIRES" CONTENT="-1">
<META HTTP-EQUIV="Refresh" CONTENT="1800; 
URL=http://localhost/MyDreamProject/sessiontimeout.php"> 

 

so i'm displaying a warning message using javascript to alert the user that his/her session is about to expire in 2 minutes, to continue click ok and to end the session click cancel.

 

herez my javascript code for tht.

<script language="JavaScript">

    var a, pageTimer;  //declare var

    function startClock()
    {
    pageTimer = 0;  //start at 0
    a = window.setInterval("tick()",60000);  //run func tick every minute....  (60 sec x 1000 ms = 1min)
    }

    function tick()
    {
    pageTimer++;  //increment timer
    if (pageTimer == 15) {warnuser()};  //if 28 min without activity
    }

    function warnuser()
    {
        if (confirm("There has been no activity for some time.\nClick 'OK' if you wish to continue your session,\nor click 'Cancel' to log out.\nFor your security if you are unable to respond to this message\nwithin two minutes you will be logged out automatically."))
        {
            
           [b] refreshme.document.location.href = "http://localhost/Project/navigation.php"[/b]
        }
        else
        {
        document.location.href="http://localhost/Project/logout.php"
        }
    }
</script>
</head>
<body BGCOLOR="#F8F5EF" class="PSPAGE" onload="startClock();">
<iframe id="refreshme" style="DISPLAY: none; LEFT: 200px; POSITION: absolute; TOP: 40px" name="theframe" width="40" height="0">
    </iframe>

but when i click ok, the session is not carrying over and getting ended after 2 minutes.

can anyone tel me how to avoid this.

i think there is an error enclosed in BOLD quoted code.

Many Thanks,

Pavan.P

Link to comment
Share on other sites

i am not to update with this however i would say it is because of

<META HTTP-EQUIV="Refresh" CONTENT="1800;

URL=http://localhost/MyDreamProject/sessiontimeout.php">

 

you have set it to 30 minutes so even if you click continue it will expire after 30 minutes because it is not being reset correctly

Regards

Mark

Link to comment
Share on other sites

refreshme.document.location.href = "http://localhost/Project/navigation.php"

 

Try using getElementById or something like this. Is the content in the i-frame reloaded? And do you call session_start() in navigation.php?

If yes thencheck if your browser sends the right Session ID

 

Try pinging the server to continue the session if the user clicks the ok button

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.