Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to set cookie expire time in php

HOW TO SET COOKIES: (to store small pieces of data in CLIENTS browser)

DESCRIPTION:
setcookie(string $name, string $value = "", int $expires = 0 (no expiry) ): bool
                     
EXAMPLE:
$value = 'something from somewhere';

setcookie("TestCookie", $value); // default no expiry
setcookie("TestCookie", $value, time()+3600);  /* expire in 1 hour */

// Print an individual cookie value- $_COOKIE["Cookie Key Name"];
echo $_COOKIE["TestCookie"];

// View all cookies
print_r($_COOKIE);

                     
FULL PARAMETER OPTIONS:
setcookie(
    string $name,
    string $value = "",
    int $expires = 0,
    string $path = "",
    string $domain = "",
    bool $secure = false,
    bool $httponly = false
): bool
                     
EXAMPLE:
setcookie("TestCookie", $value, time()+3600, "/~rasmus/", "example.com", 1);
                     
                     
Comment

PREVIOUS NEXT
Code Example
Php :: find substring regx php 
Php :: php regex string contains coringa 
Php :: create function php 
Php :: php remove and  
Php :: get all laravel validation failed messages 
Php :: php array length for loop 
Php :: magento getcollection get first 
Php :: send html email laravel 
Php :: laravel redirect url 
Php :: php check session status 
Php :: laravel log build custom channel 
Php :: insert data using mysqli in php 
Php :: php json_encode utf8 
Php :: define in php 
Php :: carbon now 
Php :: lodash tester 
Php :: php numberformatter currency without symbol 
Php :: wordpress escape string 
Php :: php check if entire array are in another array 
Php :: laravel sortby relationship column 
Php :: magento 1.9 print blank page error 
Php :: php check if object is empty 
Php :: add foreign key in laravel migration 
Php :: laravel redirect to controller method 
Php :: laravel post request search query 
Php :: get page thumbnail id wordpress 
Php :: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file laravel 
Php :: autogenerate slug for model laravel 
Php :: PHP MySQL Delete Data 
Php :: Laravel assets url issue 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =