Giter VIP home page Giter VIP logo

cookie's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar g105b avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

isabella232

cookie's Issues

Function to clear all/specific cookies

Very useful for logging out.

$cookie->clear() kills everything

$cookie->clear("user", "tracking"); kills only the two specified cookies, leaving others set.

Array cookies

Values of get methods are set to return strings. That's absolutely expected.

However, PHP implements the ability to store arrays as cookies like this:

setcookie("cookie[three]", "cookiethree");
setcookie("cookie[two]", "cookietwo");
setcookie("cookie[one]", "cookieone");

// after the page reloads, print them out
if (isset($_COOKIE['cookie'])) {
    foreach ($_COOKIE['cookie'] as $name => $value) {
        $name = htmlspecialchars($name);
        $value = htmlspecialchars($value);
        echo "$name : $value <br />\n";
    }
}

This isn't currently possible using this library, but it should be compatible, possibly utilising a getArray method.

I personally don't like the idea of cookies being set using the array syntax because it means that browsers will send each element of the array as a separate cookie which just seems like a massive waste and massive hack.

Can't pass cookie value as string

There is no toString implementation, because the cookie model does not match the other objects of PHP.Gt - for example, I think the CookieStore idea in #39 will fix this.

CookieList class

CookieList constructed with multiple Cookie objects.

  • with
  • without
  • has
  • get
  • getAll

Cookie class

Cookie represents a single cookie header with name, value and optional other fields that setcookie() takes. __toString outputs the cookie header line.

Optional fields set in PSR style withX, withoutX:

  • expiry (DateTime)
  • path (string absolute path)
  • domain (string)
  • secure (bool)
  • httpOnly (bool)

Static classes for dealing with PSR-7

With the basics taken care of in Cookie and CookieList, use static classes for reading/writing cookies to/from PSR-7 Request/Response objects.

With/without style methods.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.