How can I recognize that header() has opened actual page?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LeXbOnD
Forum Newbie
Posts: 3
Joined: Tue Apr 18, 2006 11:01 pm

How can I recognize that header() has opened actual page?

Post by LeXbOnD »

I have a login page which calls the header('Location: SOMEPAGE.php') function if the login was correct.

My question is, how can i recognise that SOMEPAGE.php has been
opened with the header function and not with any other button, link or POST method?

The code needs this information in order to recognize if the page is loaded for the first time or not (first time is on call header).



I was thinking about to save this information in the session variables but I don't think this would be an optimal solution.
Any other proposition is welcome.

I am serching something (if it exists) like the condition $_SERVER['REQUEST_METHOD']=='POST' for $_POST variables.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Set a session variable. There's no real other way that isn't easily hacked or faked.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

LeXbOnD
Forum Newbie
Posts: 3
Joined: Tue Apr 18, 2006 11:01 pm

Post by LeXbOnD »

I tried it with headers_sent() it also gives true when you click on a link and on buttons.
This means it doesn't work 4 my problem.

I'll solve it with a session variable.


Thank you 4 your help.
Post Reply