PHP Classes

How Can PHP Store Cookie Values in Files using the Package Netscape Cookie: Store and retrieve cookie values in Netscape files

Recommend this page to a friend!
  Info   View files Documentation   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2022-10-27 (29 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 14 This week: 9All time: 10,792 This week: 76Up
Version License PHP version Categories
netscape-cookie 1.0.0MIT/X Consortium ...5HTTP, PHP 5
Description Author

This package can store and retrieve cookie values in Netscape files.

It provides one class that can create cookies to store cookie parameters and set and get their values.

Another class can save the cookie values in a text file in Netscape format.

Picture of Mateo
  Performance   Level  
Name: Mateo <contact>
Classes: 13 packages by
Country: Peru Peru
Innovation award
Innovation award
Nominee: 4x

Details

Netscape Cookies

Install

composer require mateodioev/netscape-cookie

Usage

use Mateodioev\NetscapeCookie\{Config, Cookie, FileHandler};

$cookieJar = new FileHandler((new Config)
  ->setDir(__DIR__.'/cookies', true)
);

$cookieJar->setFileName('cookie.txt')
  ->add(Cookie::create('google.com', true, '/', true, 0, 'test', 'test'))
  ->add(Cookie::create('google.com', true, '/', true, time() + 3600, 'test1', 'test2')
)->save();

Output:

# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# File generate by github.com/Mateodioev

google.com	TRUE	/	TRUE	0	test	test
google.com	TRUE	/	TRUE	1666764937	test1	test2
  Files folder image Files  
File Role Description
Files folder imagesrc (3 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file readme.MD Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file Config.php Class Class source
  Plain text file Cookie.php Class Class source
  Plain text file FileHandler.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:14
This week:9
All time:10,792
This week:76Up