Jump to content

SetCookie coding help needed


acctman

Recommended Posts

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

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,

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.