Git Product home page Git Product logo

cookiejar's People

Contributors

davidpede avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cookiejar's Issues

Suggested improvements

I included a mention of your extra in a blog post, and after looking at the code, had a few ideas for you I wanted to mention:

  1. Make the expiration in days rather than seconds by multiplying the value 86400. Users can still use fractional days if they want a shorter period.

$expires = !empty($expires) ? time() + intval( ($expires * 86400)) : '';

  1. Add the cookie name and value to the $_COOKIE array so the value will be available later in the page without a reload.

  2. Log an error if setCookie() fails.

if (isset($name)) {
  $success = setcookie($name,$value,intval($expires),$path,$domain,$secure,$httponly);
} else {
  $modx->log(modX::LOG_LEVEL_ERROR, 'setCookie() - &name is required');
}

if ($success) {
    /* Make cookie available immediately */
   $_COOKIE[$name] = $value;
} else {
   $modx->log(modX::LOG_LEVEL_ERROR, 'Cookie not set');    
}

I didn't do a pull request because I wasn't sure what you'd want to do about existing installs that use seconds (e.g., convert them in the update package, or introduce a new property: &units which defaults to seconds).

error log

Can you change the log from ERROR to DEBUG?

My MODX error log is filling up with "getCookie() - Cookie name not recognised." My boss thinks it is an error, but it isn't. Most visitors won't have the cookie I am looking for on that page. It is only for special visitors to another page that get that cookie.

Periods in cookie's name

The getCookie does not work if your cookie has a period in the name e.g. if your cookie is named "local.user", however, setCookie works fine with cookies named that way.

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.