You need to pass your product.id to some controller/action where that controller/action will add the product id to the session. It cant be done on the browser side as Sessions are server driven
<%= link_to "Add to Cart", add_product_to_cart_path(:product_id => product.id) %>
and method would be something like
def add_product_to_cart
session[:cart] << params[:product_id]
end