If you are using a web browser, an error related to the cookie size (Cookie size large) may occur. Let's find out how to resolve this issue.
# Resolving Cookie Size Errors
Browser cookie errors can be confirmed with an error message on the browser window. As you can see, the message that appears when a 400 error occurs is
"this page isn't working." So, when and why does this error occur?
It corresponds to cases where the cookie size is too large.
User cookie information is stored on the browser and is sent in the header when requesting a website. It has a limited size, and ultimately, the size of the included cookie in the header used for communication is too large, resulting in an error. (The maximum size of the cookie that can be transmitted varies depending on the browser, and generally an error occurs when it exceeds 4096 bytes.)
(Screenshot) Browser errors that occur when the cookie size is large.
! Method of regenerating cookie issues.
The cookie issue does not usually occur at the beginning, but often occurs as it is used frequently. In other words, if cookies continue to accumulate, errors eventually occur.
@ How to resolve?The quickest solution is to completely delete cookies from the user's end. This means going to the browser's settings and using the option to clear cache and cookies. This method is the easiest because it removes all existing cookies.
However, it is also necessary to identify the fundamental cause. In other words, if the cookie problem occurs repeatedly on a specific website, it is necessary to examine whether excessive cookie usage is occurring on that website and to delete or modify unnecessary cookie information. Recently, it is better to consider changing the purpose of using caches or other storage to other storage APIs such as
localStorage or
sessionStorage instead of using cookies as a local storage.
We have separately specified below the possible solutions and detailed information that can be resolved from a development standpoint.
# Additional information. AWS Cognito related cookie issue.
If using AWS's Cognito as an authentication service, it's common to have cookie issues due to the large size of Cognito's cookies. When trying to log in as a different user with existing cookie information, it can exceed the limited cookie size and cause problems. This issue can be easily found in related articles, but finding a clear solution is surprisingly difficult.
@ Approaches to solving Cognito cookie issues.
There are several solutions, but the first is to create and use custom tokens. This is AWS's recommended method (see AWS Support). Simply put, it involves customizing a simple user authentication token using Lambda or similar tools.
Existing Cognito tokens contain a lot of information that is not necessary for simple authentication purposes. Therefore, the solution is to create a new token authentication by reducing unnecessary information. However, implementing a new token service requires time and effort.
Another way is to simply delete all existing cookie information before attempting to log in, so that the login process can proceed. Personally, I think this method is a simple and practical compromise.
The important thing is not to delete the information before clicking the actual login button, so the process of deleting unnecessary cookie information after clicking is necessary. In other words, the solution is to add a process that deletes unnecessary cookie information before attempting to log in.
Thus, we have looked at cookie size issues and brief Cognito cookie issues.