PHP Classes
elePHPant
Icontem

PHP SameSite Cookie Setter: Set cookie values with the SameSite flag enabled

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-04-02 (17 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: 41 This week: 41All time: 9,774 This week: 7Up
Version License PHP version Categories
samesitecookiesetter 1.0GNU General Publi...5HTTP, PHP 5, User Management
Description Author

This class can set cookie values with the SameSite flag enabled.

It can take as parameters the name and value for the cookie to be set, as well an array of options that define several optional values. The options can be for setting flags like SameSite, Secure, HttpOnly and Expires.

The class modifies the header created by the PHP setcookie() function sending a HTTP header values compatible to the one that that PHP function sends.

The class also checks if the user browser so it only sends the SameSite and other cookie flags to browsers that support it.

Innovation Award
PHP Programming Innovation award nominee
March 2020
Nominee
Vote
SameSite cookies are a means to avoid leaking information about the current user accessing a site in a way that only the site that sets the cookie has access to the cookie values.

PHP 7.3 introduced built-in support to SamSite cookies. This class allows setting same site cookies in a way that works in a compatible way in previous PHP versions.

Manuel Lemos
  Performance   Level  
Name: Ovunc Tukenmez <contact>
Classes: 14 packages by
Country: Turkey Turkey
Innovation award
Innovation award
Nominee: 6x

 

Details

SameSiteCookieSetter

This PHP class enables samesite supported cookies by modifying header created by setcookie() function. As of php version 7.3.0, new signature of setcookie() function exists. To support all php versions, this class use same parameters of new setcookie() signature. The browser agent is also checked against incompatible list of browsers.

Composer

composer require ovunctukenmez/samesite-cookie-setter
  Files folder image Files  
File Role Description
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file example.php Example Auxiliary script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Plain text file SameSiteCookieSetter.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:41
This week:41
All time:9,774
This week:7Up