user2441590
user2441590

Reputation:

php deleting cookie (cant do it via set_cookie)

I'm trying to delete my cookie when user click on logout link. But i cant do it via set_cookie and set -time. There appears header modify error - its already sent. Is there any other way to delete cookie?

Upvotes: 0

Views: 45

Answers (2)

Mike Brant
Mike Brant

Reputation: 71422

You have to delete any cookies before cookies are sent to the browser along in headers. You are getting this error because you are likely trying to unset a cookie after some sort of output has been sent to the browser. This is not allowed and will not work.

Upvotes: 0

antoyo
antoyo

Reputation: 11933

You must delete the cookie before printing any text/html.

Upvotes: 1

Related Questions