# Storing an order object in a cookie based session

**URL:** <https://www.ruby-forum.com/t/storing-an-order-object-in-a-cookie-based-session/90695>\
**Category:** Rails\
**Created:** [March 31, 2007, 1:42am UTC](https://www.ruby-forum.com/t/storing-an-order-object-in-a-cookie-based-session/90695 "2007-03-31T01:42:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [March 31, 2007, 1:42am UTC](https://www.ruby-forum.com/t/storing-an-order-object-in-a-cookie-based-session/90695/1 "2007-03-31T01:42:24Z")

</div>

I have a simple e-commerce store and am running into a problem with the  
edge rails cookie based sessions.

What I am trying to do is make the customer fill in their info, and  
click “Review my Order”. The order object is contructed, and stored in  
the session (if it passes validation). The is sent to another page  
where they can confirm all their info and press the “finalize order”  
button.

The problem is that the order object is too large to fit in the session,  
and I get a CGI::Session::CookieStore::CookieOverflow exception. The  
addresses and other customer data overflow the 4k limit.

So, without switching session stores, whats the best way to fix this? I  
don’t really want to store the order object in the session, but it  
seemed like the easiest option.

I thought about only storing the posted params from the order form, but  
that seems messy and doesn’t save much in the way data size. I thought  
about saving the order to the database, but that seems wrong since the  
customer has not actually agreed to place the order yet.

This is more or less what I am trying to do:

def review  
session[:order] = Order.new(params[:order])  
end

def finalize  
session[:order].save  
end

How can I do this without “abusing” the session by storing ActiveRecord  
object in it?
