Forum Moderators: DixonJones

Message Too Old, No Replies

Cookies newbie

help appreciated

         

lukasz

11:12 am on Jun 12, 2003 (gmt 0)

10+ Year Member



I would like to set up basic logging using cookies, however I have no knowledge or experience with that. I could not fing anything helpful on this page and in Google either.
I need something simple, which will let me know where the user who submitted form came from(refferer). Can anyone suggest some soultion, info, tutorial.
I would really appreciate.

jatar_k

4:44 pm on Jun 13, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You could use a scripting language to do this. What languages are available to you with your host?

php,perl,asp,other?

You would need to include the code on every page of your site grab the referer, if not set, and then stick it in a cookie or session variable. Then when someone fills in the form you check that variable and put it into the email or in a database.

lukasz

4:59 pm on Jun 13, 2003 (gmt 0)

10+ Year Member



thank you for your reply.
I can use perl or PHP, probably php is easier.
Could you recommend some tutorials/info?

jatar_k

5:16 pm on Jun 13, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



PHP then

you can use include [ca.php.net] to put your script into every page. Make sure it is before anything else otherwise it won't work.

Like other headers, cookies must be sent before any output from your script

You can use setcookie [ca.php.net] to actually set the cookie.

Whenever you look at functions on php.net always read through the user comments underneath. Often there is a good example similar to what you would like to do.

As for getting the referer, it is part of the $_SERVER array and is accessed like so $_SERVER['HTTP_REFERER'] [ca.php.net].

Hope that helps.