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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.