CGI::Session just don't work

I got this file to a apache/mod-ruby server and nothing is being set to
"lastaccess"

test.rhtml:
<%
require 'cgi'
require 'cgi/session'
cgi = CGI.new("html4")

sess = CGI::Session.new( cgi, "session_key" => "a_test",
                              "prefix" => "rubysess.")
lastaccess = sess["lastaccess"].to_s
sess["lastaccess"] = Time.now
if cgi['bgcolor'][0] =~ /[a-z]/
  sess["bgcolor"] = cgi['bgcolor']
end

cgi.out{
  cgi.html {
    cgi.body ("bgcolor" => sess["bgcolor"]){
      "The background of this page" +
      "changes based on the 'bgcolor'" +
      "each user has in session." +
      "Last access time: #{lastaccess}"
    }
  }
}
%>

What can be happenning?

···

--
Posted via http://www.ruby-forum.com/.

Bruno Sousa wrote:

I got this file to a apache/mod-ruby server and nothing is being set to
"lastaccess"

test.rhtml:
<%
require 'cgi'
require 'cgi/session'
cgi = CGI.new("html4")

sess = CGI::Session.new( cgi, "session_key" => "a_test",
                              "prefix" => "rubysess.")
lastaccess = sess["lastaccess"].to_s
sess["lastaccess"] = Time.now
if cgi['bgcolor'][0] =~ /[a-z]/
  sess["bgcolor"] = cgi['bgcolor']
end

cgi.out{
  cgi.html {
    cgi.body ("bgcolor" => sess["bgcolor"]){
      "The background of this page" +
      "changes based on the 'bgcolor'" +
      "each user has in session." +
      "Last access time: #{lastaccess}"
    }
  }
}
%>

What can be happenning?

A first access cannot have a lastaccess?

Also:

result = "hello"[0]
puts result

if result =~ /h/
  puts 'yes'
else
  puts 'no'
end

--output:--
104
no

···

--
Posted via http://www.ruby-forum.com/.

Discount Ed hardy tshirt (www.ebuyings.com)
Discount Ed hardy jean (www.ebuyings.com)
Discount Ed hardy shoes (www.ebuyings.com)
Discount Ed hardy handbag (www.ebuyings.com)
Discount Ed hardy other porduct (www.ebuyings.com)
Discount Nike air jordans (www.ebuyings.com)
Discount Nike Air Max 90 Sneakers (www.ebuyings.com)
Discount Nike Air Max 91 Supplier (www.ebuyings.com)
Discount Nike Air Max 95 Shoes Supplier (www.ebuyings.com)
Discount Nike Air Max 97 Trainers (www.ebuyings.com)
Discount Nike Air Max 2003 Wholesale (www.ebuyings.com)
Discount Nike Air Max 2004 Shoes Wholesale
(www.ebuyings.com)
Discount Nike Air Max 2005 Shop (www.ebuyings.com)
Discount Nike Air Max 2006 Shoes Shop (www.ebuyings.com)
Discount Nike Air Max 360 Catalogs (www.ebuyings.com)
Discount Nike Air Max Ltd Shoes Catalogs (www.ebuyings.com)
Discount Nike Air Max Tn Men's Shoes (www.ebuyings.com)
Discount Nike Air Max Tn 2 Women's Shoes (www.ebuyings.com)
Discount Nike Air Max Tn 3 Customize (www.ebuyings.com)
Discount Nike Air Max Tn 4 Shoes Customize
( www.ebuyings.com)
Discount Nike Air Max Tn 6 Supply (www.ebuyings.com)
Discount Nike Shox NZ Shoes Supply (www.ebuyings.com)
Discount Nike Shox OZ Sale (www.ebuyings.com)
Discount Nike Shox TL Store (www.ebuyings.com)
Discount Nike Shox TL 2 Shoes Store (www.ebuyings.com)
Discount Nike Shox TL 3 Distributor (www.ebuyings.com)
Discount Nike Shox Bmw Shoes Distributor (www.ebuyings.com)
Discount Nike Shox Elite Shoes Manufacturer
(www.ebuyings.com)
Discount Nike Shox Monster Manufacturer (www.ebuyings.com)
Discount Nike Shox R4 Running Shoes (www.ebuyings.com)
Discount Nike Shox R5 Mens Shoes (www.ebuyings.com)
Discount Nike Shox Ride Womens Shoes (www.ebuyings.com)
Discount Nike Shox Rival Shoes Wholesaler (www.ebuyings.com)
Discount Nike Shox Energia Wholesaler (www.ebuyings.com)
Discount Nike Shox LV Sneaker (www.ebuyings.com)
Discount Nike Shox Turbo Suppliers (www.ebuyings.com)
Discount Nike Shox Classic Shoes Suppliers
(www.ebuyings.com)
Discount Nike Shox Dendara Trainer (www.ebuyings.com)
Discount Nike Air Jordan 1 Seller (www.ebuyings.com)
Discount Nike Air Jordan 2 Shoes Seller (www.ebuyings.com)
Discount Nike Air Jordan 3 Collection (www.ebuyings.com)
Discount Nike Air Jordan 4 Shoes Collection
(www.ebuyings.com)
Discount Nike Air Jordan 5 Chaussure Shoes
(www.ebuyings.com)
Discount Nike Air Jordan 6 Catalog (www.ebuyings.com)
Discount Nike Air Jordan 7 Shoes Catalog (www.ebuyings.com)
Discount Nike Air Jordan 8 Customized (www.ebuyings.com)
Discount Nike Air Jordan 9 Shoes Customized
(www.ebuyings.com)
Discount Nike Air Jordan 10 Wholesalers (www.ebuyings.com)
Discount Nike Jordan 11 Shoes Wholesalers (www.ebuyings.com)
Discount Nike Air Jordan 12 Factory (www.ebuyings.com)
Discount Nike Air Jordan 13 Shoes Factory (www.ebuyings.com)
Discount Nike Air Jordan 14 Shoes Sell (www.ebuyings.com)
Discount Nike Air Jordan 16 Exporter (www.ebuyings.com)
Discount Nike Air Jordan 17 Shoes Exporter
(www.ebuyings.com)
Discount Nike Air Jordan 18 Offer (www.ebuyings.com)
Discount Nike Air Jordan 19 Shoes Offer (www.ebuyings.com)
Discount Nike Air Jordan 20 Manufacture (www.ebuyings.com)
Discount Nike Jordan 21 Shoes Manufacture (www.ebuyings.com)

7stud -- wrote:

Also:

result = "hello"[0]
puts result

No, the OP is correct. In the CGI library, cgi['foo'] is an array. This
is to allow for usage such as /myprogram.cgi?foo=123&foo=456

However, the next line should probably say

    sess["bgcolor"] = cgi['bgcolor'][0]

or else later on,

    cgi.body ("bgcolor" => sess["bgcolor"][0]){

But as to the problem with CGI::Session: I'm afraid it's a very long
time since I bothered with rhtml or CGI, and I'm not sure that mod_ruby
has had much care and attention.

These days I think you'll find that most people write Rack applications
(Rails and Sinatra are both layers on top of Rack), so Rack's
session-handling is much more widely tested.

Deploying a Rails or Sinatra application under Apache is very easily
done with Phusion Passenger.

···

--
Posted via http://www.ruby-forum.com/.

Brian Candler wrote:

7stud -- wrote:

Also:

result = "hello"[0]
puts result

No, the OP is correct. In the CGI library, cgi['foo'] is an array. This
is to allow for usage such as /myprogram.cgi?foo=123&foo=456

I'm not seeing that. It's my understanding that cgi handles multiple,
indentical names with cgi.params. For instance, given your url
cgi.params["foo"] would return an array. However, cgi["foo"] would
return the string "123"

However, the next line should probably say

    sess["bgcolor"] = cgi['bgcolor'][0]

or else later on,

    cgi.body ("bgcolor" => sess["bgcolor"][0]){

But as to the problem with CGI::Session: I'm afraid it's a very long
time since I bothered with rhtml or CGI, and I'm not sure that mod_ruby
has had much care and attention.

I'm not even sure what this question has to do with mod_ruby. :frowning:

···

--
Posted via http://www.ruby-forum.com/.