CGI::Session Question

O

Orion Hunter

I am using eruby/mod_ruby on a website I am developing. Everything is going
fine and dandy with the site development (as it pertains to ruby), but I
can't get my hand on session management.

I have never had to do session management before, so this is all new to me.

I tried doing the example from the Pragmatic Programmers online ruby book,
but it doesn't seem to work. Here is the code:
equire "cgi"
require "cgi/session"


cgi = CGI.new("html3")
sess = CGI::Session.new( cgi, "session_key" => "rubyweb",
"session_id" => "9650",
"new_session" => true,
"prefix" => "web-session.")
sess["CustID"] = 123
sess["Part"] = "ABC"


cgi.out{
cgi.html{
"\nHTML content here"
}
}
require "cgi"
require "cgi/session"


cgi = CGI.new("html3")
sess = CGI::Session.new( cgi, "session_key" => "rubyweb",
"prefix" => "web-session.")
cgi.out{
cgi.html{
"\nCustomer #{sess['CustID']} orders an #{sess['Part']}"
}
}

I visit test.rhtml, I see "HTML Content Here" as exected.
I visit test2.rhtml then, I get "Customer orders an", note I do NOT get the
CustID or Part printed
I revisit test.rhtml, and it stalls (ie "I get Opening page...." and it
keeps waiting, nothing happens.)

First of all, why, when I first visited test2.rhtml, did I not see the
stored info?
And secondly, why can I no longer visit either test.rhtml or test2.rhtml
once visited once ... it just never finishes loading (both IE and Firebird,
even after clearing my cookies and cache). Thanks.

_________________________________________________________________
Getting married? Find great tips, tools and the latest trends at MSN Life
Events. http://lifeevents.msn.com/category.aspx?cid=married
 

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

Members online

No members online now.

Forum statistics

Threads
473,888
Messages
2,569,964
Members
46,293
Latest member
BonnieHamb

Latest Threads

Top