Welcome to WebmasterWorld Guest from 22.214.171.124 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
PHP Includes and Cookies Passing the Cookie ILLstyle
I wrote a short PHP script that uses
The problem I have is that the CGI program the include calls requires a cookie to display certain info.
Does any one know a way to pass the cookie so the CGI can use it. The cookie that is needed is created by a shopping cart and not PHP.
Using header() works like this
header("Location: [ ...] the_path_to_page.cgi");
but I really want to do this with include().
Is there a way? ergophobe
You can't set a cookie and then use it in the same script - you need a seperate http request for both of those action.
You need to send the data from the previous page and save it as a cookie or send it as post data or some such thing. Only then is it available to the page currently being generated.
I can grab the cookie and echo it with the global $_COOKIE["the_cookie"]. So I have no problems seting it but, sending it is where Im having trouble.
I know why it won't work: It is because the CGI is seeing PHP modual as the client and not the user.
thanks for the input!
I can grab the cookie and echo it with the global $_COOKIE["the_cookie"].
Okay, I misunderstood a bit what you were doing. I thought you were setting the cookie in the same script that was calling the CGI.
seeing PHP modual as the client and not the user.
? You mean it's seeing PHP as the server and not the client?
you might pass cookies / data by setting enviroment variables before an other script ILLstyle
Yes, What I should have said is the include() calls a CGI script that needs a cookie.
The problem is when that CGI is requested it sees the PHP sever as the client and not the acctual client.
I have tried seting variables before include but this still will not work.
I also tried something like this include($_COOKIE['name'] . "/path/prog.cgi"); but this does not work.
thanks for your help
the cookie has already been set long before I use this PHP script. In this script I have no problem echoing it or setting it to a variable. I just can't seem to get it passed when using the include. Im not even sure if you can do this but I hope you can. freeflight2
include($_COOKIE['name'] . "/path/prog.cgi"); wouldn't make sense... let's say your cookie name is sessionID then you would try to include sessionID/path/prog.cgi (in addition there might be potential security issues)