php symantics of setting cookies and redirecting without getting header error

Posted by salmane on Stack Overflow See other posts from Stack Overflow or by salmane
Published on 2010-05-13T19:01:44Z Indexed on 2010/05/13 19:04 UTC
Read the original article Hit count: 171

Filed under:

I would like to do the following in php :

setcookie('name', $value, $Cookie_Expiration,'/');

then some action 

header("location:http://www.example.com")

the problem is that I get : warning: Cannot modify header information - headers already sent by (...etc )

could you please let me know what i am doing wrong and if there is a way to do this?

by the way , this code is before any output is made ...the cookie setting part works fine on its own and so does the redirection code....the combination fails

thank you

© Stack Overflow or respective owner

Related posts about php