acctman Posted February 18, 2008 Share Posted February 18, 2008 I need help with a setcookie code that will redirect a user or stop a user from accessing a page. I need help with set 3 and 4. I'm aware that this is not full proof (user can delete the cookies, user a different browser, turn cookies off, etc) but its a good deterrent that will stop most users. 1. User Logs in (login.php) 2. Check BanUser table if user exist redirect to Suspend 3. on Suspend page SetCookie to prevent the user from signing up again 4. User goes to reg.php page and the cookie redirects to Suspend Link to comment https://forums.phpfreaks.com/topic/91761-setcookie-coding-help-needed/ Share on other sites More sharing options...
uniflare Posted February 19, 2008 Share Posted February 19, 2008 put this code if banned_user is found, make sure its before any browser output or you will get errors: setcookie("cookiename","banned",time()+99999999); then on ever page that needs to check a banned user use this: if(isset($_COOKIE['cookiename'])){ if($_COOKIE['cookiename'] == "banned"){ //redirect to suspended.php exit(); } } hope this helps, Link to comment https://forums.phpfreaks.com/topic/91761-setcookie-coding-help-needed/#findComment-470160 Share on other sites More sharing options...
acctman Posted February 20, 2008 Author Share Posted February 20, 2008 i can use something like this for the redirect right header('Location: http://www.site.com/suspended.php'); Link to comment https://forums.phpfreaks.com/topic/91761-setcookie-coding-help-needed/#findComment-472070 Share on other sites More sharing options...
PHP Monkeh Posted February 20, 2008 Share Posted February 20, 2008 As long as nothing has been output to the browser before hand, of course! Link to comment https://forums.phpfreaks.com/topic/91761-setcookie-coding-help-needed/#findComment-472113 Share on other sites More sharing options...
uniflare Posted February 21, 2008 Share Posted February 21, 2008 remember to use exit(); after a header("location: ..."); call to stop script processing, (even though the client is redirected the script continues processing). Link to comment https://forums.phpfreaks.com/topic/91761-setcookie-coding-help-needed/#findComment-472572 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.