I have a problem with saving cookie before redirecting, example code:
class Example extends Controller{
public function index(){
Cookie::queue('examplecookie', 1, 525600);
$this->next();
}
public function next(){
$this->redirect();
/* Prevent this part for loading after redirect
*
* OTHER CODE ...
*/
}
public function redirect(){
header('Location: http://someurl.com');
}
}
If I am using die() after header location PHP is stopped browser is redirected and the cookie is not saved, and if die not exist browser is redirected, cookies is saved, but PHP still goes to other code. Also when using redirect() other code is loaded. Example:
public function redirect(){
return \redirect('http://someurl.com')->send();
}
This class is an example of logic, real code is more complicated :). I want to save cookies, redirect and prevent PHP to go on other code.