Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 699

Error message in php $_SESSION is couldn't be reached after it is generated in another page [closed]

$
0
0

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?


Viewing all articles
Browse latest Browse all 699

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>