Use as like below and in header you can redirect to any page.
<?php
session_start();
if (!isset($_SESSION['username'] )){
header('location:/book/index.php');
}
?>
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm working on a project , the problem is that some part of the project is made in laravel and some part in core php . Now i want to perform authentication through Auth Facade for my project . Some files are being accessed through routes and some files which are in core php are being accessed directly . so the files which are being accessed through routes Auth is working perfect But what to do for core php files , i don't want to use $_SESSION. Please suggest me a way to use Auth in my core php files.
Please or to participate in this conversation.