user2635410
user2635410

Reputation: 19

Increase limit of Cookies in a php application

== Bad Request

Your browser sent a request that this server could not understand.

Size of a request header field exceeds server limit.

Hi! I am using many cookies in my php application. Cookies are large and contains a lot of information, but all the time is showing the above error. Saying that the limit was exceeded cookie or something.

I wonder if it has the resolve to increase the limit of cookies.

Type using htaccess? Or a header in php?

Upvotes: 1

Views: 4658

Answers (3)

Emii Khaos
Emii Khaos

Reputation: 10085

Seems a problem with the server. But so many cookies is a bad design. Every time a site is requested, all cookies are sent within the header, consuming bandwidth and traffic. You ruin every mobile and slow b/w users.

You should store all information in a PHP session and send only the session cookie to the client.

http://webdesign.about.com/od/cookies/f/cookies-per-domain-limit.htm

Upvotes: 0

GordonM
GordonM

Reputation: 31750

A cookie isn't meant to be a massive store of data. Don't forget every HTTP request someone makes with your cookie requires that all the data in the cookie gets sent every time. An abnormally big cookie plus lots of users means you'll quickly get overwhelmed.

You should use a session, either PHP native or your own implementation that uses the cookie only to identify the user, and keep their actual data on the server in temp files or the database (PHP's session uses temp files by default, and you can implement a handler to make it use a database or other methods of storage).

Modern browsers also implement local storage techniques other than cookies that you can use, if you don't have resources to keep a lot of data on the server and don't mind your application not working with older browsers that don't support local storage.

Upvotes: 1

Freelancer
Freelancer

Reputation: 4770

Maybe try to add this line in your apache conf file :

LimitRequestFieldSize 16380

And restart apache

Upvotes: 4

Related Questions