# CGI::Session not sending cookie

**URL:** <https://www.ruby-forum.com/t/cgi-session-not-sending-cookie/124390>\
**Category:** Ruby\
**Created:** [December 28, 2007, 8:05am UTC](https://www.ruby-forum.com/t/cgi-session-not-sending-cookie/124390 "2007-12-28T08:05:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 28, 2007, 8:05am UTC](https://www.ruby-forum.com/t/cgi-session-not-sending-cookie/124390/1 "2007-12-28T08:05:40Z")

</div>

I’m using mod\_ruby, eruby and CGI::Session in an application. It seems  
that the cookie is never being sent, and I have no idea why. Here’s a  
simple rhtml file illustrating the problem:

% require ‘cgi’  
% require ‘cgi/session’  
% require ‘cgi/session/pstore’  
% cgi=CGI.new()  
% sess=CGI::Session.new(cgi, ‘database\_manager’ =\>  
CGI::Session::PStore, ‘session\_key’ =\> ‘hello\_session’)  
\<% sess[‘visits’] ||= 0 %\>  
\<%= sess.session\_id %\>  
\<%= sess[‘visits’] %\> visits  
\<% sess[‘visits’] += 1  
sess.close%\>

Each time this is loaded, no cookie is set, so no session ID is sent  
back to the page on reload and a new session is started each time.  
This behavior does not match any of the documentation I’ve been able  
to find, but it does match what’s described in  
[http://groups.google.com/group/comp.lang.ruby/browse\_frm/thread/84a1bddd046a9b66/d6d7e7340a5a3bb1](http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/84a1bddd046a9b66/d6d7e7340a5a3bb1)

The above poster solved his problem by passing around the session ID  
as a query parameter, but that seems to miss the point of using  
CGI::Session. Am I missing something obvious here?
