Cookie named "_web_key" exceeds maximum size of 4096 bytes

I am trying to pass a structure from one function to another in the same controller through the session but I get this error cookie named “_web_key” exceeds maximum size of 4096 bytes someone has any idea how to fix it or how else I can do the same?

def show(conn, %{"id" => id}) do
    transactions = Accounts.list_transaction()
    transaction = Accounts.get_transaction(%{"transactions" => transactions, "id" => id})
    IO.inspect(transaction)
    conn
    |> fetch_session()
    |> put_session(:transaction, transaction)
    |> render("show.html", transaction: transaction)
  end

  def change(conn, %{"private_key" => private_key}) do
    transaction = conn |> fetch_session() |> get_session(:transaction)
    {:ok, transactionn} = Accounts.set_transaction(transaction, private_key)
    IO.inspect(transactionn)
  end
end
1 Like

Is it possible for you to just store the transaction primary key in the session instead of the entire transaction?

2 Likes