PHP session is a way to store data in session variables that can be accessed across multiple pages in a website. These session variables are stored on the server and accessed using a unique session ID stored in a cookie or URL parameter.
The haveRightsOr function is a common use case for PHP session management. It is used to check if a user has specific rights or privileges, and if not, redirect them to a login page or another appropriate page.
Here is an example of how to use the haveRightsOr function:
session_start();
function haveRightsOr($right) { if (isset($_SESSION['rights']) && in_array($right, $_SESSION['rights'])) { return true; } else { header('Location: login.php'); exit; } }
haveRightsOr('admin');
?>
In this example, the haveRightsOr function checks if the user has the 'admin' right in their session variable. If they do, the function returns true. If not, the function redirects the user to the login.php page and exits.
The PHP session functionality is part of the core PHP language and does not require any additional package or library.
PHP Session::haveRightsOr - 30 examples found. These are the top rated real world PHP examples of Session::haveRightsOr from package huge extracted from open source projects. You can rate examples to help us improve the quality of examples.