Hello there

I was wondering if anyone could help me with this problem

See

I running a site where people can log in, and everytime they log in, a cookie is set, based on their username.

so when a user complete a offer, my website send a link to a Network. (example: www.Network.com/offer=9384736)

When the Network has receive the link with the offer (offer=9384736) , then they will do a postback call to my website.

Example my site is www.mywebsite.com/PB.php/offer=9384736


Then my postback script will get the offer and check for the cookie when a postback call is made from the network to my script.


So what i want is when someone giving me a postback call, a script will check for the cookie ( the user who have complete a offer)

I was just think just to put this in echo $_COOKIE["user"];, but that dident work, because it was the network who called my postback.


So have anyone any idea how i can do this?


Would really appericate if someone could help me out

Thanks!

Recommended Answers

All 13 Replies

Member Avatar for diafol

I'm confused. The cookie will be saved to user's client - so the only way the server can see it is via $_COOKIE - but only after page refresh following the original setcookie.

So with regard to the user, how is the data being set to the network? Are they redirected there and then back to your site? Is it being done via iframe or similar?

Hey ardav

Are they redirected there and then back to your site?
Yeah first my site send a link to the network, and check if its good or bad.
After they will send it back to my postback file so will get the infomation from the link.

Example www.google.com/offer=7362/stauts=1

Then it will collect offer =7362 and the status and save it in my database.

But then the problem is that it miss the user...

The link should be like this www.google.com/offer=7362/stauts=1/user=ardav
But the network doesnt support that, and they said you could do this easliy with a cookie


Is it being done via iframe or similar?

Yeah something similar with iframe ;)


Thanks for answering,

Member Avatar for diafol

If the user is logged in (with a session) you'll probably lose info via redirect to a remote site, unless it's done via one of a few ajax methods. Cross domain ajax used to be a problem, but there are ways to overcome this now. JSONP can be useful (see the jQuery documentation) as it includes a callback.

So if the remote site result is automated and doesn't require intervention (which I assume it doesn't), this approach may be useful. In what format is the response data?
json, xml, raw html??

I not 100% sure but i think it is raw html.

Member Avatar for diafol

So if it's raw html, what do you do with it - is the response data saved to your db, displayed in your page? We need a lot more info about the method of data transfer - is it iframe, jsonp... ?

Hiya,

I personally wouldn't do what you are trying to do via this method for a number of reasons, security being the most important.

I would suggest storing the users/purchase information into a database and then retrieving the information when asked from the callback. That way, the information is there long after the user has left your website.

Hey hey

See, when a network call make to my website, they call with a link (www.google.com/offer=9483/ip=192.168.0.01/status=1)

My website will only accsess the networks ip, so if a random guy copy the calling link and type it in the adress bar, they will get accsess denied.

When my site got the link it will get the infomation ( offer=9483 + ip=192.168.0.01 + status=1)

When it got the information it will bring it to the database, like now,
It will not paste the offer or the ip into the database, but the status will be updated on the user.

-------------------------------
Database

Username - Status - IP
ME...............12........192.168.1.1
------------------------------

So when someone call and the status is 1 (lets say 1 = Good 2 =Bad, if the link bring status = 2, it will stop) they will be updateing the status in the database with 1+

So then i would get 13 points...

And its not displayed on the page

I am not an Expert in this, but i think it is jsonp


Every user who register on the site are storeed in the database, the call back is just an updateing of the status for example.

Member Avatar for diafol

OK, I'm not much wiser. SO you're actually getting all the data and it's being saved to your DB. The problem is that the user can't see it. Is that right?

I don't know how your sites take to each other, but would it help to refresh the page after the callback finishes? Would that work?

but would it help to refresh the page after the callback finishes?
hehe i wish it was so easy, but i dont think that would work out

The only thing i want is to know who have done the task, so i can update their stats

Right now the postback and all the other thing works ok, but the problem is that there are no username from the calling back from network, so can update their stats.
Like now, if someone complete their task, nothing happen. Cuz the postback dont know which user who comeplete the task ;/

Member Avatar for diafol

Oh, now I get it. Well, you may be able to save the data to a session:
$_SESSION

So when you come to using a query to insert to the DB, you can use username from $_SESSION or even user_id as $_SESSION - whatever you need. The only concern is that if the page is redirected to the remote site, session data may be lost. That's why I'm thinking about the use of an iframe of other ajax method.

You have really just answered your own question here. You have to find a way to tie the user id to the post back information.

What information does the postback send? Is there a common denominator here that can be used on both sides? i.e. like product id or something? If so, you can create a session array that holds your user information and product info and then double check that with the session array.

Okay, im abit cofuesd about the session thing, cuz how will this work?
Remember it is my network who will call back to my site with a link, so how will my script then collect the session from the user?

dmtp i have think about that, but im not pretty sure how i would do that.
The link that my network send to my website is like this (www.google.com/id=384/status=1/ip=192.168.1.1/transactionid=847384).

Could you help me with that? Have heard someone said that would might work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.