Ubiquity
stable

Quick-starts

  • with console
  • with web-tools

Installation & configuration

  • Ubiquity-devtools installation
  • Project creation
  • Project configuration
  • Devtools usage

Controller

  • URLs
  • Router
  • Controllers
  • Events
  • Dependency injection

Scaffolding

  • CRUD Controllers
  • Auth Controllers

Models and ORM

  • Database connection
  • Generation
  • ORM
  • DAO

Http

  • Request
  • Response
  • Session
  • Cookie
    • Cookie creation or modification
    • Retrieving a Cookie
      • Testing the existence
      • Using a default value
    • Deleting a cookie
    • Deleting all cookies

Views

  • Views
  • Assets
  • Themes

RichClient

  • jQuery Semantic-UI

Contents

  • Normalizers
  • Validators
  • Transformers
  • Translation module

Security

  • Security
  • Security module
  • ACL management

Rest

  • Rest

Webtools

  • Webtools

Contributing

  • Contributing
  • Coding guide
  • Documenting guide

Deployment

  • Servers configuration
  • Ubiquity optimization

Extras

  • Ubiquity commands
  • Composer management
  • Ubiquity Caching
  • Ubiquity dependencies
  • OAuth2 client module
  • Async platforms
Ubiquity
  • Docs »
  • Cookie
  •   Ubiquity website
  • Edit on GitHub

Cookie¶

Note

For all Http features, Ubiquity uses technical classes containing static methods. This is a design choice to avoid dependency injection that would degrade performances.

The UCookie class provides additional functionality to more easily manipulate native $_COOKIES php array.

Cookie creation or modification¶

use Ubiquity\utils\http\UCookie;

$cookie_name = 'user';
$cookie_value = 'John Doe';
UCookie::set($cookie_name, $cookie_value);//duration : 1 day

Creating a cookie that lasts 5 days:

UCookie::set($cookie_name, $cookie_value,5*60*60*24);

On a particular domain:

UCookie::set($cookie_name, $cookie_value,5*60*60*24,'/admin');

Sending a cookie without urlencoding the cookie value:

UCookie::setRaw($cookie_name, $cookie_value);

Testing the cookie creation:

if(UCookie::setRaw($cookie_name, $cookie_value)){
     //cookie created
}

Retrieving a Cookie¶

$userName=UCookie::get('user');

Testing the existence¶

if(UCookie::exists('user')){
     //do something if cookie user exists
}

Using a default value¶

If the page cookie does not exist, the default value of 1 is returned:

$page=UCookie::get('page',1);

Deleting a cookie¶

Deleting the cookie with the name page:

UCookie::delete('page');

Deleting all cookies¶

Deleting all cookies from the entire domain:

UCookie::deleteAll();

Deleting all cookies from the domain admin:

UCookie::deleteAll('/admin');
Next Previous

© Copyright 2017-2021, phpmv Revision e8bd0775.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: stable
Versions
latest
stable
2.4.12
2.4.11
2.4.10
2.4.9
2.4.8
2.4.6
2.4.4
2.4.3
2.4.1
2.4.0
2.3.11
2.3.10
2.3.9
2.3.3
2.3.1
2.3.0
2.2.0
v2.1.4
v2.1.3
v2.1.2
v2.1.0
v2.0.11
v2.0.10
v2.0.9
v2.0.4
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.