PHP Classes

File: lib/cookie.php

Recommend this page to a friend!
  Classes of Muhammad Umer Farooq   PHP Cookie Management Class   lib/cookie.php   Download  
File: lib/cookie.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP Cookie Management Class
Store and retrieve HTTP request cookie values
Author: By
Last change: Apply fixes from StyleCI
Date: 6 years ago
Size: 1,018 bytes
 

Contents

Class file image Download
<?php

/**
 * Create instence of class.
 *
 * @return object
 */
function cookie()
{
    return new
Cookies();
}

/**
 * Set the cookie value.
 *
 * @param $name of cookie
 * $value of cookie
 * $expire of cookie
 * $domain of cookie
 * $secure of cookie
 * $httponly of cookie
 *
 * @return bool
 */
function set_cookie($name, $value, $expire, $path, $domain, $secure, $httponly)
{
    return
cookie()->set(['name'=>$name, 'value'=>$value, 'expire'=> time() + $expire, 'path'=> $path, 'domain'=>$domain, 'secure'=>$secure, 'httponly'=>$httponly]);
}

/**
 * Get the cookie value if set.
 *
 * @param $name of cookie
 *
 * @return string
 */
function get_cookie($name)
{
    return
cookie()->Get($name);
}

/**
 * Delete the cookie if set.
 *
 * @param $name of cookie
 *
 * @return bool
 */
function delete_cookie($name)
{
    return
cookie()->Delete($name);
}

/**
 * Check cookie is set or not.
 *
 * @param $name of cookie
 *
 * @return bool
 */
function is_cookie($name)
{
    return
cookie()->IsCookie($name);
}