Handling Multiple Cookies

Experts:

I'm currently working on an MVC project that handles one step of a 2 step authentication via cookie data.  I want to have multiple cookies that expire at different times, though I've noticed that all of my cookies are being stored in one "cookie file" (as it appears in windows explorer when you look at the cookies).

I can access the cookies and their data separately correctly within the code, but it seems if I expire one or the other, it causes both of them to be no longer passed by the browser.

Can I have multiple cookies in the same file with multiple expiration date/times?  Can a single site have multiple cookie files?

Thanks for any input!
LVL 12
piattndAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

guru_samiCommented:
- Yes you can create more than one cookie with separate expiration date.
- Cookies are stored per domain, so you will see a single file per domain.

- Are they separate cookie or storing multiple values in same cookie?

Can you share you code.
0
piattndAuthor Commented:
They are multiple cookies and each cookie has multiple values.  Is the cookie limit of 4KB actually the individual cookie size or is that the file size that represents all cookies for that domain?

I think I may have figured out the expiration thing.  The expiration listed on the file itself I believe is the date of the longest valid cookie.  I'm doing more testing on the expiration issue, but I'll post my code if I can't get it figured out.
0
piattndAuthor Commented:
I was able to resolve the issue.  My code for setting the expiration was not actually returning the cookie again, so it was a bonehead error.

I still have the question though on the cookie size limit.  I know the typical limit to stick by is 4KB, but is that for the total size of all cookies for the domain (the size of the single cookie file) or is that truly the size of each individual cookie?
0
guru_samiCommented:
4KB per cookie.
Most browsers support cookies of up to 4096 bytes. ....

Most browsers allow only 20 cookies per site; if you try to store more, the oldest cookies are discarded. Some browsers also put an absolute limit, usually 300, on the number of cookies they will accept from all sites combined.

Reference
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
piattndAuthor Commented:
Sorry it took me so long to close.  Thanks a lot for your help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.