Jump to content

code executed even after die();


onedumbcoder

Recommended Posts

I have a problem with my code.

 

I have something similar to this

 

 

session_start();
...
if($activesession)
{
header("Location: home.php");
die();
}

session_destroy();

 

the problem is that even though the if statement is true and it redirects the page, it still executes session_destroy()!

I have no idea why, anyone have a clue?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/168012-code-executed-even-after-die/
Share on other sites

it is redirecting the user?

The it that is performing the redirect is the browser. Php happily continues executing the rest of the code on the page. A page "protected" by a log in check that does not prevent the rest of the code on that page from being executed is not protected against anything.

 

Here is a case where an admin panel was hacked by not preventing the code on its' pages from being executed - http://www.phpfreaks.com/forums/index.php/topic,258141.0.html If you have a form page, a form processing page, or a page with any kind of content, you only need to ignore the header() redirect and you can access the pages like there was no log in check present.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.