Skip to content

A golang package for storing cookies in netscape cookie jar file

Notifications You must be signed in to change notification settings

vanym/golang-netscape-cookiejar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

netscapecookiejar

netscapecookiejar is a golang package for storing cookies in netscape cookie jar file

Usage

Format looks like

www.example.com	FALSE	/	TRUE	1338534278	cookiename	value

Importing

import netscapecookiejar "github.com/vanym/golang-netscape-cookiejar"

Marshal and Unmarshal

cookie, err := netscapecookiejar.Unmarshal(".example.com\tTRUE\t/\tTRUE\t1338534278\tcookiename\tvalue")
line, err := netscapecookiejar.Marshal(cookie)

Cookie jar

subjar, err := cookiejar.New(&cookiejar.Options{})
jar, err := netscapecookiejar.New(&netscapecookiejar.Options{
    SubJar:        subjar,
    AutoWritePath: "cookies_auto.txt",
    WriteHeader:   true,
})
file, err := os.Open("cookies_read.txt")
_, err = jar.ReadFrom(file)
file.Close()
file2, err := os.Create("cookies_write.txt")
_, err = jar.WriteTo(file2)
file2.Close()

About

A golang package for storing cookies in netscape cookie jar file

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages