Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8087499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:47:40+00:00 2026-06-05T18:47:40+00:00

I have problem SIMILAR to preventing form data reposting, but not quite the same

  • 0

I have problem SIMILAR to preventing form data reposting, but not quite the same. That question has been answered many times. The advice given, like header redirects and sessions, didn’t work for me. Whether they failed because of my incorrect implementation, lack of experience solving this problem, or both, I don’t know.

I have an intranet web app that, when launched, extracts data from a different server, transforms it, and then loads it to a database local to the application. What happens is that if the user refreshes the main page, the ETL scripts run again and duplicate the data.

How can prevent the ETL scripts from re-running? For this app, there is no reason to refresh the page. Should I simply prevent refreshes altogether on that page, if that’s even possible? I’m probably overlooking something simple. So, I’m open to suggestions.

UPDATE:

I got this test code to work on the index.php page. So, I’m going to build on that to craft a solution. I’ll keep you posted.

session_start();
$_SESSION['views'] = 1; // store session data
echo "Pageviews = ". $_SESSION['views']; //retrieve data
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:47:42+00:00Added an answer on June 5, 2026 at 6:47 pm

    I’ve outlined a very basic example for you of how you could use a session to make sure your scripts are only run once per visit (per user). The key point here is the script would still run more than once in the event of more than 1 user using the system.

    To get around this I would simply use your local db to keep track of when the scripts were last run. So you could have a datetime column in your db that would keep track of when the last ‘run’ was performed.

    1. So in your PHP code (in replace of checking the $_SESSION) you would query the db to retrieve the datetime value
    2. Once you have the last run date/time you would check if the current date/time is past the allowable ‘update time’ (for example 24hrs)
    3. If the time is past your alloted ‘update time’ say 25hrs the code would run and you would update the datetime to now()
    4. If the time is within your alloted time, nothing would happen, no update of db and your scripts would not run.
    5. Repeat 3 – 4.

    This above way would make the number of users irrelevant as all checks will be performed against a central data set (i.e. your db). It would also probably be a bit more robust as it will be independent of browser and user.

    Anyway here is a session (per user) method:

    <?php
    /* 
     * Set PHP sessions to suit:
     * 
     * session.gc_maxlifetime is the number of seconds after which the data 
     * will be seen as garbage and cleaned up (session life) - 
     * 
     * Set to 86400 to in theory make the session last 24 hours - adjust this 
     * number to suit.
     * 
     * If this doesn't work you may have to try and adjust the php session lifetime
     * in either the php.ini file directly or htaccess file.
     * 
     */
    ini_set('session.gc_maxlifetime',86400);
    /* 
     * not strictly neccessary as this is default setting (but just to make sure)
     * This will keep the cookie alive (the link to your session) until the user
     * closes their browser. 
     * 
     * You could set it to > 86400 if you want that extra bit of certainity that 
     * the session will get renewed @ 24 hrs / the time you wanted to.
     */ 
    ini_set('session.cookie_lifetime',0);
    // Start PHP session
    session_start(); 
    
    // Check if the session is empty / exists (which it will be on first page entry)
    if ( empty($_SESSION['hasVisited']) ) {
    
      /* 
       * Add your ETL script logic here:
       * 
       * This will only run on the first visit to the site
       */   
    }
    
    // Now set the session as the scripts have run once
    $_SESSION['hasVisited'] = true;
    
    // Continue on with your app...................................................
    
    ?>
    

    Let me know if I missed what you were trying to do or you want further explanations on anything?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have checked this similar question, but the suggestions did not solve my problem:
I have a problem that similar to : this question But I still don't
I suppose similar problem would have been discussed here, but I couldn't find it.
Similar to this question: link However I have already mastered that. My problem is
I have a problem similar to this question which was previously asked but my
I have a problem similar to this question but with an added complication: MySql,
Still quite new to Python. I have a problem similar to this question .
I have similar problem to one discussed here , but with stronger practical usage.
My problem is similar to Django Passing Custom Form Parameters to Formset Ive have
Here is my problem I have arraycollection with the attribute Month with similar data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.