Jump to content

[SOLVED] Cookie data not returned when accessed from public IP


stuartmarsh

Recommended Posts

Hi All,

I am writing a page to use cookies but when I access the page through my public IP nothing is returned.

If I access the page through http://localhost/test.php, the data is returned.

This is the test code I am using:

<?php

$value = 'something from somewhere';

setcookie("TestCookie", $value);


// Print an individual cookie
echo $_COOKIE["TestCookie"] . "<br>";
echo $HTTP_COOKIE_VARS["TestCookie"] . "<br>";

// Another way to debug/test is to view all cookies
echo "<pre>"; print_r($_COOKIE); echo "</pre>";
?> 

Anybody got any idea why it doesn't work through the public IP?

 

Link to comment
Share on other sites

this is true,

I'm not sure what you exactly mean, but remember that a cookie set in a script located on http://localhost/ can't be read from another domain, say http://127.0.0.1/.

 

My point was this, If you don't set an expire value, the cookie is a session cookie, and it never creates the cookie file, it is an ether cookie that vaporizes as soon as this particular session is gone, and is only visible to the individual browsers session.

 

So once you put in the expiry then you get into the realm you pointed out

Link to comment
Share on other sites

I have examined the http headers and the cookie created and IS being sent back to the server.

This is where it gets weird.  I did a var_dump of $_SERVER and normally there is an item called

 ["HTTP_COOKIE"]=>
  string(15) "test=test+value"

.

When I look at the data sent over the Internet it looks like this

 ["HTTP_XOOKIE"]=>
  string(15) "test=test+value"

.

 

What is HTTP_XOOKIE and why is the cookie data set there?

Link to comment
Share on other sites

thebadbad: This isn't a typo, this is actually what is displayed.

 

I have discovered that my problem was being caused by our firewall.

We are using a FortiGate and it uses something called Protection Profiles to scan inbound packets.

There is an option called Cookie Filter that was causing the Cookie to be passed back as Xookie.

It's a weird problem that I've never seen or heard of before.

 

!!Live and Learn!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.