0

I'm building a deeplink system into a very complex website which needs cookies and other context set-up before the deeplink will work (otherwise the page gets redirected back to the home page - not much use).

So I've added a module which provides the deeplink entry point through hook_menu:

deeplink/<deeplink-parameters>

The callback builds the context, adds the cookies and then redirects to the actual required page.

So much for the theory. It doesn't work and I can't figure out why not.

In order to replicate a completely "virgin" request I've been using incognito windows, restarting the server and clearing caches before each test. In the test version I'm not redirecting to a new page, just outputting a line of text to display the page.

But even attempting to generate a simple test cookie with a long life (REQUEST_TIME + 999999) fails. No cookie created. The setcookie() function is returning TRUE (cookie created), which implies there is no problem.

The only cookies I can see are the ones created by JavaScript on the page itself, and a couple created by the Zeus wrapper (there are no Zeus rules to delete cookies on standard Drupal pages).

Just in case the cookie isn't visible on the first page I am also then moving to another page but still no cookie. Seems like it just isn't being created despite what the function says.

Additional data: There is also no PHP Session ID cookie.

Any thoughts as to why the cookies are not appearing?

EDIT: Looking at this further, I moved the setcookie() function into index.php (before the Drupal bootstrap), and it still wasn't creating the cookie.

So rather than issuing the deeplink command as above I simply went to the home page. And it's still not creating the cookie (as an anonymous user, with everything cleared before we start).

Only when I moved away and into the more complex part of the site did the test cookie appear. At the same time that the PHP Session ID cookie appeared. Is this a hidden dependency? No cookies can be created through PHP unless there's a PHP session ID?

2
  • It would help if you could show the code you are using to set the cookie ;) Jun 21, 2016 at 9:37
  • setcookie('test', 'test', time() + 99999); I spent all of yesterday working through a zillion different options and scenarios. Putting the setcookie() in various places in the code, including outside of a function so it got executed immediately. Jun 21, 2016 at 9:44

1 Answer 1

0

The world has not turned upside-down.

It turned out that Zeus was indeed eating cookies of anonymous accesses, I had to go through every Zeus rule (we have a lot) until I found it.

Testing with Zeus bypassed demonstrated the cookies were created correctly.

Bloody Greek Gods, wandering in uninvited and eating all the cookies...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.