On Jul 9, 10:44 am, Pål Bergström <li...@ruby-forum.com> wrote:
> Why doesn't this work in a controller, or in a file in a module in /lib:
>
> require 'cgi'
> cgi = CGI.new
> test = cgi.cookies["mycookie"][0]
>
Rails doesn't use CGI anymore as the interface between it and the
outside world (it uses rack instead) which probably broke that.

Controllers have an instance method called cookies which returns a
hash like object containing your cookies.

Fred

> cgi.cookies doesn't get the cookie.
>
> But this cgi script does:
>
> require 'cgi'
> cgi = CGI.new('html4')
> cookie_name = 'mycookie'
> val_string = cgi.cookies[cookie_name][0]
> cgi.out {
>     cgi.html {
>         cgi.head { cgi.title {"Cookies"} } +
>             cgi.body {
>        cgi.p {"name: #{cookie_name}" } +
>              cgi.p {"value: #{val_string}"}
>         }
>     }}
>
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to