**Partial Success** SESSION countdown timer possible?

This section is for posting questions which are not directly related to WYSIWYG Web Builder.
Examples of off topics: web server configuration, hosting, programming related questions, third party scripts.

Note that these questions will generally not be answered by the administrators of this forum.
Post Reply
MGD4me
 
 
Posts: 278
Joined: Tue May 02, 2017 11:56 pm
Location: British Columbia, Canada

**Partial Success** SESSION countdown timer possible?

Post by MGD4me »

I have used the built-in countdown java script in the past, where a pre-determined time/date is entered on the configuration page. I was wondering if there might be a way to use this script to watch a SESSION variable, instead of a hard-coded time/date?

I would like to monitor the time remaining, after a person logs into the password protected area of a website. In a similar manner where someone would log into a bank, or airline's website, where the session is monitored and allows the client to refresh (for lack of a better term) their login after some interval of time.

The ability to 'refresh' would be the best outcome, but at least if I could display a live countdown, this might be sufficient to alert the user to take action.

Thanks for any ideas...
Last edited by MGD4me on Wed Jan 18, 2023 9:31 pm, edited 1 time in total.
User avatar
BaconFries
 
 
Posts: 5619
Joined: Thu Aug 16, 2007 7:32 pm

Re: SESSION countdown timer possible?

Post by BaconFries »

Maybe the following Read from
This is another easy way to do this
https://stackoverflow.com/questions/268 ... hp-session
Session reset
https://www.php.net/manual/en/function. ... -reset.php
MGD4me
 
 
Posts: 278
Joined: Tue May 02, 2017 11:56 pm
Location: British Columbia, Canada

Re: SESSION countdown timer possible?

Post by MGD4me »

Thanks, BF...

I had a quick look at your suggestions, and I think that would do the job nicely.

I appreciate your ongoing help! 8)

Norm
User avatar
BaconFries
 
 
Posts: 5619
Joined: Thu Aug 16, 2007 7:32 pm

Re: SESSION countdown timer possible?

Post by BaconFries »

Welcome
MGD4me
 
 
Posts: 278
Joined: Tue May 02, 2017 11:56 pm
Location: British Columbia, Canada

**Partial Success** SESSION countdown timer possible?

Post by MGD4me »

Thanks again BF for your suggestions.

I have made significant progress toward my goal, so I post a link to my results so far.

The countdown portion of the attached project works, and I can use it 'as-is'. I currently have it installed on the Member page of a small website, and it may have to remain as such.

Issue #1: The countdown information is displayed on a red background, which is what I want. But, I only wish to display the remaining time once a pre-set 'alert' time is reached. Unfortunately, my script throws up the blank background during the whole time it is waiting for the 'alert' trigger. Since I can place the HTML 'box' over an existing part of the page header where there is already a red background, then the 'unwanted' blank red countdown virtually disappears. I'd rather place the HTML 'box' NOT in the header.
Question: does anyone know how to eliminate the initial red background display, while the script is busy waiting for the 'alert' trigger? That would make it ideal.

Issue #2: Totally unnecessary, but I tried to include a button to refresh the page (which would in essence restart the 'expires_by' time, both during the alert period, and finally once the log in timer ('expires_by') hits zero. I have next to no javascript experience, and I suspect that having php running on the server, while javascript runs in the client, this may not be practical. If this is not do-able, I would be happy just solving issue #1.

For testing purposes, you can just upload the wbs project 'as-is' to your server. There are test values pre-loaded which negates the requirement to being logged in. You can reload the page over and over, and it will begin with an expiry timer value of 25 seconds, and an alert value of 20 seconds. Change these if you wish, for testing.

For actual production use, you will need to look for a couple of clearly noted lines which must either be deleted (test values) or lines substituted. Look for lines 6 to 8, and 53 and 54. That should be it!

My 'button' code is at the bottom, at line 101. I may have to delete all this. :(

My project file contains the HTML 'box', mentioned above, and must be inserted on the 'landing page' or Member logged in page, and be set to 'php', since the script will want to monitor the $_SESSION[expires_by'] time remaining.

Thanks for looking!

https://drive.google.com/file/d/1vkdpcd ... sp=sharing
Post Reply