Delete cookies to solve this error cookie named "_web_key" exceeds maximum size of 4096 bytes

I am sending a list of structures through a session and the memory of cookies or something like that is filling up very quickly so there is some way to delete those cookies or the session

image

I was trying this way but I don’t know the methods very well so I don’t know what password to send to eliminate what I keep in the session and in the cookies so that this error does not happen

You can update and delete session data with Plug.Conn or increase size via Plug.Cowboy.
Is better to not grow up by a lot.

UPDATE

conn
|> put_session(:my_var, my_data)

OR 

conn
|> put_session(:my_var, nil)

DELETE

conn
|> delete_session(:my_var)
1 Like

And there is no way to pass that list from one function to another that are on the same controller other than through session? is that I have two functions in the same controller and one is the one that receives a list and sends it to the other function through the session because I didn’t find another way
look here send
image

and here I receive it:

because I did what you told me but when I send you a very long list I get the error again

How big is your data?
You can also temporary save to an ETS table.

It’s a risky to store big objects in session due to exactly the reasons you encountered. It’s limited size and must be minimally utilised.

Just make a cache that has a key that easily fits in a cookie, pointing at your data. Like ETS.

and with ETS if it can be created in one and call in another function is that I am trying and within the same function if it allows me to obtain the value that it stores in the ETS but if I call it from another function I already get an ArgumentError error
image

Or use a server side session store, which does this already.

1 Like

can you give me an example

Use a Plug.Session.Store, which unlike Plug.Session.COOKIE does store session data on the server. https://hexdocs.pm/plug/1.8.3/Plug.Session.html

2 Likes