Jump to content


Photo

* Solved *Setting cookies via includes


  • Please log in to reply
4 replies to this topic

#1 stephenk

stephenk
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 06 August 2006 - 12:06 PM

Hi,

I have a simple script uploaded to mydomain.com/test.php containing the following:

<?php

setcookie("tester");
echo "tester";

?>

I then have a file hosted locally with the following code:

<?php

include "http://www.mydomain.com/test.php";

?>

When I run the local file, the echo text is shown, however the cookie isn't set. If I place test.php locally also, the include works as expected.

Thanks for any help,
Stephen

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 06 August 2006 - 12:12 PM

This is because when you include the URL it gets the php script from the webserver which will parse the scrip and then just send you the output of the script.

So in theory your webserver visited the other server and got the cookie set not the person visiting the page..

Regards
Liam
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 stephenk

stephenk
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 06 August 2006 - 01:16 PM

Thanks for your help.
Is there a function to include the actual code and not just the output. I can't place the actual code in the script for security reasons, hence the reason Im using includes.

Regards,
Stephen

#4 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 06 August 2006 - 01:32 PM

you would have to use include('test.php') and link localy instead of froma  website.
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#5 stephenk

stephenk
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 06 August 2006 - 02:21 PM

Thanks for the help. Im going to have to just put the actual code in the file and use an include to get the private bits.

Regards
Stephen




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users