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

[eluser]Ryubr[/eluser]
Hi,

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!
#2

[eluser]johnwbaxter[/eluser]
Sessions in codeigniter now support having the userdata in the db instead of a cookie. That should solve your problem!
#3

[eluser]Ryubr[/eluser]
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
#4

[eluser]phpoet[/eluser]
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.
#5

[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.
#6

[eluser]johnwbaxter[/eluser]
I've gotta stop reading derek allards blog, upcoming becomes real and current in my head...
#7

[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!
#8

[eluser]johnwbaxter[/eluser]
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