How to prevent user from bookmarking URLs?
forms, get, html, php, url
Solution
Quick and dirty solution: Add a timestamp parameter to your urls, like:
<p><a href="/blank.php?name1=value1&name2=value2&time=<?php echo time(); ?>">next page</a></p>
Then, on the page, check if the timestamp is older then a certain duration:
if(!isset($_GET['time']) || time() - intval($_GET['time']) > 60*60) {
header('Location: index.php');
}
$name1 = $_GET['name1'] ;
$name2 = $_GET['name2'] ;
echo htmlspecialchars($name1);
echo htmlspecialchars($name2);
So if a link is older than one hour (60 seconds times 60 minutes), it is redirected to the home page!
But this method is not very user friendly! You should better try to build your links so they never get old content when visiting!
Problem
My website's webpages displays webpages by using `GET` to retrieve variables from a predefined URL. For example the code on the first page: `index.php` ``` <p><a href="/blank.php?name1=value1&name2=value2">next page</a></p> ``` The second page: `blank.php?name1=value1&name2=value2` ``` $name1 = $_GET['name1'] ; $name2 = $_GET['name2'] ; echo $name1 ; echo $name2 ; ``` This way webpages are created on the spot and displayed kind of like a CMS and Iuse this method for all the webpages my site has, but if a user bookmarks a tab they will have out of date information for that webpage because that page content is contained in the URL. EDIT: If I were to use `post` would their be a better way of conveying that information to the new webpage? instead of: ``` <form method="post" action="blank.php"> <input type="hidden" name="name1" value="value1"> <input type="submit"> </form> ```