-1

How can I unset session in PHP , I try to make flash session . I searching some topic that same as my problem and I found try to put exit(); adfter header:location but it didnt work for me

in my Controller

 Session::set('add_message', 'added');
return redirect('/list','',array('detail_id'=>$id));

in my redirect function I alredy add exit();

function redirect($as, $parameter=array(), $query_string=array()) {
        header('Location: '.route($as, $parameter, $query_string), true, 301);
        exit;
    }

in my html I try to echo session add_message and unset it but it didnt unset

if ($_SESSION('add_message')) {
            echo $_SESSION('add_message');
            unset($_SESSION['add_message']);
          }
Pardeep
  • 2,153
  • 1
  • 17
  • 37
test1321
  • 331
  • 1
  • 8
  • 23

2 Answers2

-1
$_SESSION('add_message') = false;
Aman Kumar
  • 4,533
  • 3
  • 18
  • 40
심심이
  • 59
  • 3
-1

Try This

session_unset();    // remove all session variables
session_destroy(); // destroy the session
Pardeep
  • 2,153
  • 1
  • 17
  • 37