Giter Site home page Giter Site logo

phco's Introduction

PHCO

PHCO is Cookie Management Library

PHCO is a utility class for managing HTTP cookies in PHP applications. It provides methods for adding, updating, removing, and accessing cookies, as well as checking their expiration status.

Features

  • Add: Add a new cookie with a specified name, value, and optional expiration time.
  • Update: Update the value and expiration time of an existing cookie or create a new one if it doesn't exist.
  • Remove: Remove a cookie with the specified name.
  • Get: Retrieve the value of a cookie with the specified name.
  • Exists: Check if a cookie with the specified name exists.
  • Expired: Check if a cookie with the specified name has expired.
  • Active: Check if a cookie with the specified name is active (not expired).
  • GetExpiredDetails: Retrieve the remaining time until expiration of a cookie with the specified name.
  • MakeExpired: Set a cookie with the specified name to expired.
  • GetAll: Retrieve all available cookies.

Usage

Adding a Cookie

To add a new cookie:

PHCO::add('username', 'john_doe', 60); // Expires in 60 minutes

Updating a Cookie

To update the value and expiration time of an existing cookie or create a new one if it doesn't exist:

PHCO::update('username', 'jane_doe', 30); // Expires in 30 minutes

Removing a Cookie

To remove a cookie with the specified name:

PHCO::remove('username');

Retrieving a Cookie Value

To retrieve the value of a cookie with the specified name:

$username = PHCO::get('username');

Checking if a Cookie Exists

To check if a cookie with the specified name exists:

if (PHCO::exists('username')) {
    // Cookie exists
} else {
    // Cookie does not exist
}

Checking if a Cookie Has Expired

To check if a cookie with the specified name has expired:

if (PHCO::expired('username')) {
    // Cookie has expired
} else {
    // Cookie is still active
}

Retrieving Remaining Time Until Expiration

To retrieve the remaining time until expiration of a cookie with the specified name:

$remainingTime = PHCO::getExpiredDetails('username');

Setting a Cookie to Expired

To set a cookie with the specified name to expired:

PHCO::makeExpired('username');

Retrieving All Available Cookies

To retrieve all available cookies:

$allCookies = PHCO::getAll();

phco's People

Contributors

sakibweb avatar

Watchers

 avatar

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.