Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict refresh option?

Tags:

php

mysql

refresh

There is a problem. I don't want that people would be able to refresh one page on my site. How can I do it?

like image 919
good_evening Avatar asked Nov 19 '25 09:11

good_evening


1 Answers

Refresh is a browser side solution. You can't restrict it from server side.

What you can do is actually to use PHP's SESSION to actually prevent people from visiting any page twice.

<?php

session_start();

if(!isset($_SESSION['disablethispage'])){
    $_SESSION['disablethispage'] = true;
    // serving the page first time

}else{
    // visited before or page was refreshed

}

However user is still able to come back to the same page if he/she removes the session cookie for your website.

If you're talking about double posting, you might want to look at the POST-REDIRECT-GET Solution. See: http://en.wikipedia.org/wiki/Post/Redirect/Get

like image 112
mauris Avatar answered Nov 22 '25 00:11

mauris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!