I have a ticketing website and I want to avoid users from opening index.php
after they logged in. When they are logged in, they are automatically redirected to dashboard.php
. Because my Login page is my index.php
file and I want to customize it for login only. I want to write some code like below in PHP or jQuery or JavaScript:
<?php
$call_user = $site_calls->call_user;
if ($call_user <> 0){
//redirect to ("dashboard.php");
}
?>
If someone already logged in , they are redirected to dashboard.php
whenever they want to access to index.php
page.
`Simplest code, working shown below. Set a session variable after login, check for that session variable in index.php, if its set, redirect to dashboard.php`
<?php session_start(); if(isset($_SESSION["user"])) //change to your session variable { header("Location: dashboard.php"); } ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.