CGI::Session / mod_ruby problem.

R

Robert Gleeson

Hi everybody,

I am making an AJAX call to login.rhtml, in login.rhtml a new session is
created, and then I use javascript to reload the page to
/interface/index.rhtml where i attempt to continue the session created
in login.rhtml but everytime I do this I get an ArgumentError(from what
ive read means no session exists.) I am using mod_ruby/eruby to do
this.. The code I am using is posted below :

-- login.rhtml --
session = CGI::Session.new(cgiObject,'database_manager' =>
CGI::Session::pStore,
'session_key' => '_rb_sess_id',
'session_expires' => Time.now + 30 * 60,
'prefix' => 'sessions_pstore',
'new_session' => true)

session['username'] = cgiObject['username']
session.update
session.close

-- interface/index.rhtml --
session = CGI::Session.new(cgiObject,'database_manager' =>
CGI::Session::pStore,
'session_key' => '_rb_sess_id',
'prefix' => 'sessions_pstore'
'new_session' => false )
puts session['username']
 
M

Martin Boese

The code looks okay to me what you can do:

1. Add 'session_path' => '/' to the options of CGI::Session.new if
your scripts are in different directories.
2. Check in your browser if the cookie is really set (firefox ->
Preferences -> privacy -> Show cookies)
3. Check if the login.rhtml can see the cookie before you set it again. (e.g.
new_session => 'false' ... puts session.inspect). As a test.

martin
 
R

Robert Gleeson

Thanks Martin, I set "session_path" => '/' in the interface/index.rhtml
file which resulted in the problem being solved. Thanks a million for
your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top