i am executing this private method by call in another part of class. the session is started already at the top of script(source of problem is not related with session_start()).This is where I generate the error message :
private function isValidOthers($parentId, $title, $keywords, $description, $status, $slug){ if (empty($parentId) || empty($title) || empty($keywords) || empty($description) || empty($status) || empty($slug)) { $_SESSION["error"] = "All inputs are necessary. Please fill all fields."; header("Location:admin/category_add.php"); exit; }}
And this is where i want to handle the error message (admin/category_add.php) :
<?phpsession_start();var_dump($_SESSION);if (isset($_SESSION["error"])) { echo " Swal.fire({ icon: 'error', title: 'Error!', text: '" . $_SESSION['error'] . "', timer: 3000, showConfirmButton: false });";unset($_SESSION['error']);}
if I uncomment the line var_dump($_SESSION)
i can reach the error message as i expect. but i want to handle my error message without reaching $_SESSION
.
I think i misunderstood one simple point, is there anyone to help?