Welcome Guest, Not a member yet? Register   Sign In
zip a string


My goal is to reduce a cookie size (as you know it is limited to 4kb) and the idea is to have this string bigger than 4kb "zipped" to be saved to the cookie. As plain text it will be great to add more data tah the 4kb.

Of course when i get the cookie i will need to unzip it. So the idea is to have it as string, or some encoded text that can be reversed.

I think it would be possible by zip the string and get the contents. But i don't see how the zip class can help on this.

Any ideias :-)

Thanks in advance!

Sessions in codeigniter now support having the userdata in the db instead of a cookie. That should solve your problem!

Thanks, but actually i need to save the info on a persistent cookie and as it have a lot of ids i would require that i use something like a gzdeflate function to "compress" the data , but not as binary, because if i do it when save on the cookie as the UTF-8 it will need to be converted so all the sapce i want to save will be gone with the conversion of 1 char to UTF-8 encode.

For example, i have this string C32_080720H5V1G7V3C33_080620H5V1G7V3

I would like to reduce it to half of its size so save cookie space at the same time be able to add more data as i talked before Smile

Is it really true that the userdata can be stored in the database now? According to the CI documentation, only information used to validate the session is stored in the database and the actual user data is still in a cookie on the client's machine. You may want to look into using something like DB_Sessions which adds another column to the ci_sessions table for the userdata and does not put the user data in a cookie.

[eluser]Pascal Kriete[/eluser]
Yes it's true, but it's not released yet. You can grab it from the SVN (along with the new validation library and other good stuff).

Compressing (and then decompressiong) your cookie adds more processing overhead than the data is worth.

I've gotta stop reading derek allards blog, upcoming becomes real and current in my head...

[eluser]Derek Allard[/eluser]
[quote author="audiopleb" date="1220403892"]I've gotta stop reading derek allards blog, upcoming becomes real and current in my head...[/quote]

No no, don't stop! I need at least one other person to share my reality!

I'm sorry derek, but unless you have EE 2.0 out the door within 1 week i'm not reading your blog anymore...

Theme © iAndrew 2016 - Forum software by © MyBB