Disable Renavigation to same page ??

anuj_web

New Member
Messages
145
Reaction score
0
Points
0
Hi,

How can i disable a person from coming back to a page where he has worked lastly...atleast show a msg and not the actual page content

using Javascript or PHP...

can i use an html code in b/w javascript to do this ??

Code:
 <meta http-equiv="Refresh" content="4;url=http://mysite.x10hosting.com">
 
Last edited:

woiwky

New Member
Messages
390
Reaction score
0
Points
0
That html will work, but you'd still need a little php to determine if the user has been there before. There are two reasonable ways to do this. One would be to use sessions, which is rather easy, but users can get them cleared by logging out or closing their browser. You could set the sessions up like:

PHP:
session_start();
$_SESSION['name_of_page'] = 1;
And then checking if the page is set in the user's session to determine if they should be redirected. All you'd have to do is use unset($_SESSION['name_of_page']); to allow them access again. But as I said, users can get their sessions cleared.

The other way is by storing which user viewed which page and possibly at what time in the db. This is a little bit harder, but most reliable. You'd have to make a new table in the db to store this information. And either use the user's IP or their id to identify them in the table, depending on if you want this to happen to logged in users only(id) or guests and members alike(IP).
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
Just a little remark, don't use <meta> refresh, the user can disable this in his browser.
The better alternative is once more, php.
PHP:
//Page to redirect to.
$page = "http://www.google.com";
//Html response
//eg. 404: page not found
//307: temporarly redirect, etc
$htmlcode = 307;
header("Redirect:".$page, true, $htmlcode;

Note: header() must ba called before any output! (whitelines are output too!)
 
Top