Forum Moderators: coopster & phranque

Message Too Old, No Replies

big problem - need help! setting cookies

         

scorpion

1:16 am on Dec 6, 2002 (gmt 0)

10+ Year Member



Is anyone here familiar with CCBILL?

Anyway, here's the problem:

The below link:
refer.ccbill.com/cgi-bin/clicks.cgi?CA=xxxx&PA=yyyy

sets a cookie on the users system.

if I type it in the address bar or do a PHP header redirect it works (verified with netscape cookie manager)

However it does NOT set the cookie if I call it using fopen
fopen("http://refer.ccbill.com/cgi-bin/clicks.cgi?CA=xxxx&PA=yyyyy", "r");

I need to be able to set the cookie using this code from within a php tagged segment of an html/php document...

Any ideas why it doesn't work using fopen and it works using the normal ways?

[edited by: jatar_k at 6:27 am (utc) on Dec. 6, 2002]
[edit reason] delinked [/edit]

mavherick

2:01 am on Dec 6, 2002 (gmt 0)

10+ Year Member



Well you see, the fopen call is made on the server side, so technically the user never request the page but the server does. Now what happens to the cookie in that case i don't know, but it sure won't be set on the user machine.

is there a way around it using the fopen code? no idea, sorry.

mavherick

scorpion

3:59 am on Dec 6, 2002 (gmt 0)

10+ Year Member



can you set a cookie from domain1.com FOR domain2.com?
that is, can you run a php script on domain1.com (setcookie(,,,,".domain2.")?

scorpion

6:51 am on Dec 6, 2002 (gmt 0)

10+ Year Member



never mind, i found the solution (I think!) assuming of course you can do a header refresh AFTER other functions, my idea is like this at the TOP of index.php (in pseudocode)

<?php

are cookie's enabled by browser?
IF NO --> break;
IF YES -->
FETCH mycookie
IF mycookie EXISTS break;
IF mycookie doesn't exist
set mycookie
header_refresh(ccbill_refercode&RETURNTO=index.php)
?>
<HTML> (your webpage) </HTML>