PHP script runs again on "view source"

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
pinehead
Forum Newbie
Posts: 14
Joined: Sat Oct 13, 2012 11:51 am

PHP script runs again on "view source"

Post by pinehead »

OK,

My php code re-runs whenever i do a "view source" inside of chrome. Is this normal? I'm trying to create an access token that expires when the page loads. Problem is, when you do the viewsource it creates a new access token.

Thank,s
User avatar
mecha_godzilla
Forum Contributor
Posts: 375
Joined: Wed Apr 14, 2010 4:45 pm
Location: UK

Re: PHP script runs again on "view source"

Post by mecha_godzilla »

Hi,

I get this sometimes (though not all the time) when I'm working on an application of mine that can only be connected to over an SSL connection - when I try to view the page source in Firefox I get the source code for the login page instead i.e. as if no login credentials were sent.

I'm not sure if I can suggest anything to fix this issue because it may just be the way that some browsers work, but if you only need to view the page source for testing purposes you could echo() out the access token somewhere in your page template - this would tell you at least whether the access token is being regenerated on each page load as expected.

Hopefully some other forum members will have some more useful suggestions :)

HTH,

Mecha Godzilla
JWeiry
Forum Newbie
Posts: 2
Joined: Tue Feb 12, 2013 6:56 pm

Re: PHP script runs again on "view source"

Post by JWeiry »

@OP: Yes that is normal. I think the way in which 'View Source' works has changed since early versions of browsers. (Although i am unsure if even the early browsers in fact did load the page again)

If you are use Chrome's element inspector... you can actually view the source of the current page by not using the elements tab, but by viewing the file on the "Resources" tab.

You want to be looking in the "Frames" -> "(mypage.php)", and then underneath the sub items (Images,Scripts,Stylesheets) it should list the php file itself. You can click on this to show the source for the currently loaded page.
Post Reply