Skip to content

PHP classes to help merge crappy legacy code that depends on cookies to utilize sessions instead

License

Notifications You must be signed in to change notification settings

pteague/useless-legacycookie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

useless-legacycookie

PHP classes to help merge crappy legacy code that depends on cookies to utilize sessions instead.

<?php
session_start();
use Useless\Legacy\Cookie;
use Useless\Legacy\SimpleHashMap;

$cookie = new Cookie( new SimpleHashMap( $_SESSION ), new SimpleHashMap( $_COOKIE ) );
// @TODO switch this to false once all legacy code is replaced
$cookie->setUseLegacyCookies( true );

// replace old code:
$success = setcookie( 'foo', 'bar', 60*60*24*7, '/' );
// with:
$success = $cookie->setCookie( 'foo', 'bar', 60*60*24*7, '/' );


// replace old code:
$foo = $HTTP_COOKIE_VARS['foo'];
$foo = $_COOKIE['foo'];
// with:
$foo = $cookie->getCookie( 'foo' );

About

PHP classes to help merge crappy legacy code that depends on cookies to utilize sessions instead

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages