Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Making A Better PHP Ban System (Need Help)

Featured Replies





<?php

session_start();




include ("connection.php");

if ($_SESSION['banned'] == 1)

die ("Your Account Has Been Disabled, Please Contact An Administrator!");




?>

 

Can someone modfi this from using sessions to something more better, when i ban a user they wont be banned untill they login again so the session can be set, Need something that will say if theres 1 = in the database (1 means your banned) for that user then kill the script, Next time they refresh the page, It be alot easier and better, or something that can destroy the sessions if it == 1 so they have to login again to apply the sessions.





<?php

session_start();




include ("connection.php");

if ($_SESSION['banned'] == 1)

die ("Your Account Has Been Disabled, Please Contact An Administrator!");




?>

 

Can someone modfi this from using sessions to something more better, when i ban a user they wont be banned untill they login again so the session can be set, Need something that will say if theres 1 = in the database (1 means your banned) for that user then kill the script, Next time they refresh the page, It be alot easier and better, or something that can destroy the sessions if it == 1 so they have to login again to apply the sessions.

 

um why would u even consider using sessions for banning someone the moment the browser is closed the session is distroyed

You could still use sessions.

 

For my login system, I tend to set user related session info straight from my database, as soon as the user logs in.

 

You could have a field in your database with 'banned', 'user_level' etc.

 

And as soon as the password/username has been verified, retrieve those values and store them in their respectable session indexes.

 

Then do a check

if($_SESSION['banned'] == 0) {
//whatever you want to do with them here
}

 

I don't have to worry about users being able to modify session info as mine session data is all encrypted. :D

Edited by Samus

You could still use sessions.

 

For my login system, I tend to set user related session info straight from my database, as soon as the user logs in.

 

You could have a field in your database with 'banned', 'user_level' etc.

 

And as soon as the password/username has been verified, retrieve those values and store them in their respectable session indexes.

 

Then do a check

if($_SESSION['banned'] == 0) {
//whatever you want to do with them here
}

 

I don't have to worry about users being able to modify session info as mine session data is all encrypted. :D

 

um ur missing the point i think its better practice to have a field in the database that says banned, then check if that isset to 1 for banned user or 0 for non banned user like rallport said sessions are temporary

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.