Forum Moderators: coopster

Message Too Old, No Replies

Run PHP script once on first load

         

smallcompany

6:32 am on Apr 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



We used Perl script to get referring info like domain and keywords. Variables would be applied to the URL so they can get carried between the pages.

Now we would like to change that and have PHP script get and explode the referrer and pass variables to a cookie or session, so we get clean URLs.

For me, this means I need that PHP script to load only once at the first page load (when users just enter the site, no matter how they came on).

What is the easiest way to load the script on initial site visit only? Can that be done from .htaccess?

I'm trying to figure a way where I don’t need to add any of this PHP
code to actual HTML pages.

Thanks

jatar_k

11:52 am on Apr 17, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I guess you could use auto_prepend but I think an include would be easy

then have the included script check to see if the GET/SESSION/COOKIE vars have already been created, if so, don't do anything

smallcompany

4:49 pm on Apr 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So, this would have include in every page of the site and then the whole PHP would be outside.

Furthermore, since this stuff should be loaded before anything else, the include should be on the very top of the code.

Am I correct?

Thanks

jatar_k

5:21 pm on Apr 17, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if I understand correctly then

yes, include on every page and the php code would be in a single file, not on each page

and yes

include would be before anything else on each page