Forum: Ruby How carry data between 2 page by ruby session

C038403192dcc27dcb9fc91b3dc9dc9d?d=identicon&s=25 Ferdous ara (ferdous)
on 2013-09-06 15:47
Hi
I am trying to carry logged_in username from one  page to different page
by cgi session.
but it does not work , can any one please tell me what i am doing wrong

page1.rb :

#!/usr/bin/ruby
        "

#!/usr/bin/ruby

require 'cgi'
require 'cgi/session'

cgi = CGI.new
puts cgi.header
loged_user="testuser"


sess = CGI::Session.new( cgi, "session_key" => "user_prov",
                          "session_id"  => "9650",
                          "new_session" => true,
                          "prefix" => "web-session.")
sess["logged_id"] = "#{loged_user}"

puts "#{sess['logged_id']}"


page2.rb :  (the username should show here by session)



#!/usr/bin/ruby
require 'cgi'
require "cgi/session"
print "Content-type: text/html\r\n\r\n"
cgi=CGI.new
sess = CGI::Session.new( cgi, "session_key" => "user_prov",
                               "prefix" => "web-session.")

puts "---"
puts "#{sess['logged_id']}"



but in page2 it does not show the username ...

how can this be achieve ??

thanks
D12499a206176a299c630971e9f5bada?d=identicon&s=25 adam overstreet (Guest)
on 2013-09-06 20:11
(Received via mailing list)
Hopefully this doesn't throw a wrench in your project but I created a
project that required a login and I used the devise gem.
They have great documentation and there is a great screencast:
http://railscasts.com/episodes/209-introducing-devise

Good luck,
Adam
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.