I'm having difficulty trying to figure this out. I'm not even sure if it's possible.. I will appreciate any sort of help!!
On site A,开发者_开发问答 I have a link (an affiliate type link) that redirects to site B. When clicking the link on site A, I use this script to redirect..
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $url);
exit;
the $url var is just site's "A" URL. What I can't figure out is how to pass a variable from the redirection script onto site B without using a query string in the URL itself (for example, http://www.siteB.com/?var_to_pass=something
)
Also, both sites are on a different server so I'm not sure if sessions will work. But between sites I have a script which I hope I can use someone to achieve what I need.
There's only one way to pass data between sites via a redirection, just as you're doing, in the URL via query vars. You can't make a browser redirect via POST, so GET's your only option.
You can do it with a POST and javascript but it's not as pretty (or as reliable). Simply have a form that's submitted by the body onLoad event.
You just want to hide the variable from people? You can do this:
www.sitea.com -> (redirect) -> www.siteb.com/incoming?var=blah
# then
www.siteb.com/incoming?var=blah -> (redirect) -> www.siteb.com/
It will happen so quickly that the user won't even see and the end result is that siteb gets the variable from sitea and the user ends up on a clean looking url.
Alternatively you can use curl (but note, it won't redirect, if you want to redirect you have to use solutions descrbed above), to send and receive variables from one server to another, just when receive make sure to save your variables somewhere(database)..
精彩评论