lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Nov 05, 2007, at 19:59, Matt Campbell wrote:

Has anyone written a Lua module that can parse a Mozilla-format cookies.txt file into a data structure of some kind, and generate a cookies.txt file from a data structure of the same form? I'd like something similar to the cookielib module shipped with Python 2.4 and later.

Something like this perhaps?

local Data = require( 'Data' )
local HTTPExtra = require( 'HTTPExtra' )
local HTTPCookie = require( 'HTTPCookie' )
local aCookie = HTTPCookie( '$Version="1"; Customer="WILE_E_COYOTE"; $Path="/acme"; Part_Number="Rocket_Launcher_0001"; $Path="/acme";Shipping="FedEx"; $Path="/acme"' )

print( Data( aCookie ) )


The HTTPCookie code is based on Xavante's Cookies module: codeweb/cookies.lua?rev=1.1;content-type=text%2Fplain;cvsroot=xavante

Which itself is inspired by CGILua cookies: cgilua/cookies.lua?rev=1.7;content-type=text%2Fplain;cvsroot=cgilua