Forum Moderators: coopster

Message Too Old, No Replies

Putting a url into a session.

         

big_jimmi

2:32 pm on Jan 17, 2007 (gmt 0)

10+ Year Member



Hi folks

Im fairly new to php - having only used it in my lastest 2 sites.

Is it possible to grab the refering url and insert it into the session array?

i.e. if a user comes from bobswebsite.com, bobswebsite will be added into the session with a view to write it to a database...

Many thanks in advance for any advise you can give me.

Cheers

Twixly

3:08 pm on Jan 17, 2007 (gmt 0)

10+ Year Member



$url = $_SERVER['HTTP_HOST'];

Grabs the hostname into $url variable

check more info on $_SERVER on php.net if you want to see more info stored in this reserver array.

Twixly

3:16 pm on Jan 17, 2007 (gmt 0)

10+ Year Member



ops, meant :
'REMOTE_HOST'

Sorry. HTTP_HOST is the host the page is on if I remember correctly

coopster

4:13 pm on Jan 17, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, big_jimmi.

Twixly is on track, but I'm guessing the $_SERVER [php.net] variable you want is

HTTP_REFERER
(misspelling is correct, a carryover from its inception). However, that particular variable may not always be present and cannot be trusted.

big_jimmi

4:43 pm on Jan 17, 2007 (gmt 0)

10+ Year Member



Hi guys

Thanks for your prompt replies.

Ok I'll try what you've recommended - but if its not as reliable as you say can you think of any other/better way I can store what site a certain sign up or application came from?

thanks again