1

I found that 301 redirect response in my web service written in PHP doesn't carry custom http headers and custom cookie values if the visit is the very first visit. What I am not sure is whether this is how 301 redirect is supposed to work or whether this is just a matter of how to write my PHP code?

If this is unclear, please clarify and I will make the question clearer. My question is on how http protocol is supposed to behave in this case.

kee
  • 10,969
  • 24
  • 107
  • 168
  • possible duplicate of [Why can't I set a cookie and redirect?](http://stackoverflow.com/questions/1621499/why-cant-i-set-a-cookie-and-redirect) – Barmar Oct 17 '14 at 05:32
  • @Barmar the symptom seems to be different. I am seeing this from Chrome, Firefox and Safari and my question is more on how this is supposed to behave from http protocol standpoint. – kee Oct 17 '14 at 05:43
  • I found that by googling _http redirect cookie_. There were lots more hits, maybe some of them will be more to your liking. – Barmar Oct 17 '14 at 05:45
  • @Barmar, one more I am asking about 301 redirect not 302 which is in the link you provided. – kee Oct 17 '14 at 05:45
  • I think all redirects will be similar, so it doesn't matter whether it's 301 or 302. – Barmar Oct 17 '14 at 05:46

2 Answers2

5

It is possible to add custom HTTP headers to a 301 Redirect response (HTTP 301 Moved Permanently).

For an example of this, visit http://www.hotmail.com which is now redirected to http://www.outlook.com and carries some custom HTTP headers on its 301 redirect response.

Svein Fidjestøl
  • 3,106
  • 2
  • 24
  • 40
5

ANY response can contain cookies and custom headers. There is nothing in the HTTP spec to prevent that.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770