maxso Posted October 5, 2008 Share Posted October 5, 2008 I have a php file that can set a cookie but i dont want it to be editable to the users. so i need to give them a php file that includes this php file that will set the cookie. How can i do this? Link to comment https://forums.phpfreaks.com/topic/127132-inserting-a-php-files-script-into-another/ Share on other sites More sharing options...
budimir Posted October 5, 2008 Share Posted October 5, 2008 include("cookie.php"); Link to comment https://forums.phpfreaks.com/topic/127132-inserting-a-php-files-script-into-another/#findComment-657627 Share on other sites More sharing options...
maxso Posted October 5, 2008 Author Share Posted October 5, 2008 thanks but does this work if i say include("www.mydomain.com/cookie.php"); ? Link to comment https://forums.phpfreaks.com/topic/127132-inserting-a-php-files-script-into-another/#findComment-657655 Share on other sites More sharing options...
budimir Posted October 5, 2008 Share Posted October 5, 2008 Yes, it will work! Link to comment https://forums.phpfreaks.com/topic/127132-inserting-a-php-files-script-into-another/#findComment-657659 Share on other sites More sharing options...
wildteen88 Posted October 5, 2008 Share Posted October 5, 2008 Yes, it will work! Not it wont! It'll only include the output from cookie.php. It wont include the PHP code. Link to comment https://forums.phpfreaks.com/topic/127132-inserting-a-php-files-script-into-another/#findComment-657673 Share on other sites More sharing options...
maxso Posted October 5, 2008 Author Share Posted October 5, 2008 so will it set the cookie? Is there any other way to include the cookie without them being able to change like the date and stuff. Link to comment https://forums.phpfreaks.com/topic/127132-inserting-a-php-files-script-into-another/#findComment-657694 Share on other sites More sharing options...
tendrousbeastie Posted October 5, 2008 Share Posted October 5, 2008 No, fraid not. If you 'include' or 'require' scripts from other servers it will only include the output from that script. I.e. if you script contained "echo 2+2;", the if you included it from a different server all you would be including is "4". If your script was designed to set a cookie, then when you included it it would set a cookie on the remote server, not your one. Link to comment https://forums.phpfreaks.com/topic/127132-inserting-a-php-files-script-into-another/#findComment-657701 Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2008 Share Posted October 5, 2008 Actually, because the included php code is parsed on the remote server, the remote server will send a cookie to the client's browser, but it will match the domain of the remote server and it won't be accessible to the server where the script with the include() statement was executed. Link to comment https://forums.phpfreaks.com/topic/127132-inserting-a-php-files-script-into-another/#findComment-657704 Share on other sites More sharing options...
maxso Posted October 5, 2008 Author Share Posted October 5, 2008 basicly i want a cookie from the users remote server for other servers to read. I am getting confused ??? Link to comment https://forums.phpfreaks.com/topic/127132-inserting-a-php-files-script-into-another/#findComment-657705 Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2008 Share Posted October 5, 2008 Cookies are domain specific. A browser will only send cookies with any http request that match the domain that is in the http request. Link to comment https://forums.phpfreaks.com/topic/127132-inserting-a-php-files-script-into-another/#findComment-657711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.