Cookiejar without cgi

How do you create a cookiejar? I googled:

ruby cookiejar example create help -bowling -rails -python -java -php
-pottery -ceramic -lyric -lyrics

and just can’t find an example. Here’s what I have:

require ‘rubygems’
require ‘curb’
require ‘cgi’

cookie = CGI::Cookie.new
(“SID”,“domain=.google.com”,“path=/”,“expires=1600000000”)

puts cookie.inspect
puts cookie.to_s

#add cookie to cookiejar, and use curb
#c = Curl::Easy.http_post “https://www.google.com/accounts/
ClientLogin”,

How can I do that without cgi?

thanks,

Thufir

Thufir wrote:

Here’s what I have:

require ‘rubygems’
require ‘curb’
require ‘cgi’

cookie = CGI::Cookie.new
(“SID”,“domain=.google.com”,“path=/”,“expires=1600000000”)

puts cookie.inspect
puts cookie.to_s

How can I do that without cgi?

By emitting a Set-Cookie: header directly?
http://en.wikipedia.org/wiki/HTTP_cookie#Implementation

You can always look at the source of CGI::Cookie to see what it does,
and incorporate the bits you want. What’s the reason for not using it?

On Feb 1, 6:05 am, Brian C. [email protected] wrote:
[…]

How can I do that without cgi?

By emitting a Set-Cookie: header directly?http://en.wikipedia.org/wiki/HTTP_cookie#Implementation

You can always look at the source of CGI::Cookie to see what it does,
and incorporate the bits you want. What’s the reason for not using it?

What I meant to ask is how to do that from the curb library. There’s:

curl = Curl::Easy.new(‘http://example.com/’)
curl.cookies = ‘auth=abcdef; ASP.NET_SessionId=big-wall-of-text;’
curl.perform

http://blog.codefront.net/2009/06/18/better-cookie-support-in-curb/

but can the curb API create the same cookie as the cgi API, and, if
so, how? For convenience, I’d like to use just as few different API’s
as possible, where possible. Alternately, how can that cookie created
from the cgi API be used by the curb API? Add the cookie to a
cookiejar which curb can access?

-Thufir

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs