0

I can´t set cookies with setcookie().

I thought it´s really easy to set cookies with this, but it won´t work...

What I found was this: Something to add cookies in a header with "set-cookies". This should solve my problem (I guess, didn´t try by now).

Set-Cookie Header With Multiple Cookies

The next problem: How to add multible headers for cookies correctly?

In the php manual I didn´t find anything for this (or even set-cookie header).

Anyone got a solution for this?

this is what i got by now, but the browser won´t accept my cookies (returns false when I test it)

setcookie('testCookie','testValue',time()+31536000,'/','www.mydomain.com');
Community
  • 1
  • 1
Top Questions
  • 1,862
  • 4
  • 26
  • 38
  • 1
    Is your setcookie() function located before any text output? (echo, error display, etc.) – bh42 Nov 05 '13 at 12:44

1 Answers1

1

You have to call setcookie before any content is outputted to the page (e.g. echo or print statements).

fire
  • 21,383
  • 17
  • 79
  • 114