B
B
Begetan2011-05-11 00:34:21
PHP
Begetan, 2011-05-11 00:34:21

PHP can't set smart cookie

Hello %username%!

There is a website that sets this cookie:

Set Cookie: Cart=1689949376348582,1,2534374306259466;


I also want to set the same cookie in my script, I write:
setrawcookie('Cart', '1689949376348582,1,2534374306259466', 0 ,'/');


Does not work, does not come to the client.

Writing:
setcookie('Cart', '1689949376348582,1,2534374306259466', 0 ,'/');


Works, only comes in url-encoded form:
Set-Cookie: Cart=1689949376348582%2C1%2C2534374306259466;


The application does not understand this.

Question: how to make a cookie with commas? Why is setrawcookie not working? I've already broken my head!

Server Apache/2.2.16 (Debian)
X-Powered-By PHP/5.3.6-8

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Peretyatko, 2011-05-11
@Begetan

try
header('Set Cookie: Cart=1689949376348582,1,2534374306259466;');

B
Begetan, 2011-05-11
@Begetan

Thank you ,
it works!
True, in my case, ngnix is ​​still hanging out and not everything is in order there.

B
Begetan, 2011-05-16
@Begetan

There was one problem with the header (Set-Cookie)
When the command is called again, the header overwrites the old setting. The solution is: The second parameter in the header command is the header rewrite flag. Maybe someone will come in handy.
header ("Set-Cookie: {$cookie1}", FALSE);
header ("Set-Cookie: {$cookie2}", FALSE);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question