Page 1 of 1

how to compress a cookie value

Posted: Tue Feb 14, 2006 4:24 am
by jasongr
Hello

I need to store some very long text inside a cookie using php's setcookie
the problem is that sometimes the text is too long for the browser to handle

and I get the following error:
400 Bad Request

Your browser sent a request that this server could not understand.
Size of a request header field exceeds server limit.

Is there a way to compress the value I am about to save in the cookie
and then to uncompress it again when I read the value from the cookie?

I just need to make sure that the encoding of the compressed value will be
legal for the browser to store in the cookie so that the uncompression will work

Is this possibe?
I would appreciate leads to PHP compression solutions if possible

regards

Posted: Tue Feb 14, 2006 8:12 am
by Jenk
I have to ask.. what are you storing in the cookie?

Posted: Tue Feb 14, 2006 8:53 am
by feyd
if this will be used on multiple servers, you'll still have a problem with size limitations of cookies. There are several alternates, such as storing it in session variables or a database.

gzcompress() may be of interest, it has links to other compressions php supports.