I have a php web application that uses big cookies to store a lot of users data. If I set mod_gzip on the apache server, will it compress only the page content or will it compress the cookies also?
No, it compresses only the content. Cookies are sent in the headers, which are never compressed.
The compression will not happen for cookies with mod_gzip, but you can always compress the cookie data yourself if you know that it is going to be big. Compress the data when you create the cookie, and decompress it when you read the cookie. Be sure to verify a signature on the data before decompressing to help avoid DoS attacks against your code.
I think you're focusing on the wrong issue here.
At which point you feel that compressing the cookie(s) might be a good idea, you're clearly misusing the cookie system.
Store minimal data in the cookies, like a unique id to a login context or whatnot, don't store the entire user data in the cookies.
Basically what I'm getting at is, you should never feel the need to have the cookies compressed. If you do, you're doing something wrong.
And no, to answer your question, it won't compress the cookies. They're sent separately from the content.
Sometimes we need to store lots of data for (legal) tracing purposes like in the Ads market. Then we need to store cookies with lots of traceable info to improve our ad angines to prevent a user from, for example, seeing the same ads many times. We might not use it but then the time taken to access the db retrieving info that's already in the user side begins to grow when counting for millions hits/day, plus db connections, + server usage, etc..
For sure we store the minimum info (integers only) but anyway it could grow up easily after some time.