Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Simple eRuby question

Reply
Thread Tools

Simple eRuby question

 
 
Chris Dutton
Guest
Posts: n/a
 
      05-15-2004
Hi,

I'm using eRuby and mod_ruby to write some simple *.rhtml pages (I just
switched to a host with decent support for Ruby), but there's one thing
that's got me scratching my head.

How do I set cookies?

eRuby's handling all of the HTTP headers for, so by the time I get
control back, it's too late. If I recall correctly, there's a
"no-header" flag, but I don't really want to have to menually output the
normal headers on every page.

I'd appreciate any light you might be able to shed on this.

Thanks,
Chris
 
Reply With Quote
 
 
 
 
paul vudmaska
Guest
Posts: n/a
 
      05-18-2004
Chris Dutton <(E-Mail Removed)> wrote in message news:<WCxpc.465258$Pk3.248561@pd7tw1no>...
> Hi,
>
> I'm using eRuby and mod_ruby to write some simple *.rhtml pages (I just
> switched to a host with decent support for Ruby), but there's one thing
> that's got me scratching my head.
>
> How do I set cookies?
>
> eRuby's handling all of the HTTP headers for, so by the time I get
> control back, it's too late. If I recall correctly, there's a
> "no-header" flag, but I don't really want to have to menually output the
> normal headers on every page.
>
> I'd appreciate any light you might be able to shed on this.
>
> Thanks,
> Chris


Something like this is working on my host:
%> cookie.rhtml

<%
begin
require 'cgi'

COOKIE_NAME = 'mycookie'

cgi = CGI.new

if cgi.cookies[COOKIE_NAME][0]

puts 'cookie found : ' + cgi.cookies[COOKIE_NAME][0]

else

puts 'settting cookie'

cookie = CGI::Cookie.new ({'name'=>COOKIE_NAME,'value'=>'cookie
value','expires'=>Time.now + (2400*24*365)})

cgi.header({'cookie'=>[cookie]})

end

rescue Exception

puts $!
end

%>

So the headers might not be the problem.

aul
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I cannot seem to find a simple way to install eruby on a centos develbox Xeno Campanoli Ruby 2 09-13-2007 09:27 PM
simple eruby -- including files Chad Perrin Ruby 5 03-30-2007 06:05 AM
documentation on eRuby, eRuby resources Dude Ruby 2 03-22-2007 07:17 AM
erb question (was eruby question) Greg Brondo Ruby 0 04-07-2004 09:50 PM
eruby setup question Greg Brondo Ruby 3 04-07-2004 09:47 PM



Advertisments