Passing GET variables using a header in PHP

I encode "user-only" access for the site, and when the user is not logged in to the control panel, it is redirected to the login page.

<?php session_start(); $logged= $_SESSION['logged']; if(!$logged){ header("Location:http://www.someweb.com/system/login.php?logged_off=1"); } ?> 

but the login page does not get the GET variable, can you tell me what I'm doing wrong?

+2
source share
1 answer

When using the location of the header, you must call exit();

Why? Since the execution of the script will not be completed.

Parentheses () are optional, exit is a language construct, not a function, and it's actually a bad idea (PHP has more work if they exist), just a terrible habit that I have.

+3
source

Source: https://habr.com/ru/post/1215281/


All Articles