Category: php
Using Cookie Variables in PHP
Setting cookies in php is pretty straight forward. There is a php function:
setcookie();
This function must be called before any anything else on the page or it will fail. There are two options to address this.Use ob_start to Buffer content
- You can either make sure that setcookie() is the first thing you call in your script - which is often just not a possibility.
- Or, You can use the ob_start() and ob_end_flush() functions.
ob_start() and ob_end_flush() will buffer the content on a page until after the setcookie() variable has been created.
Expire Value is a Unix Timestamp
The expire value for php cookies must be a UNIX time-stamp:
Use the php time() function
time() + 1800_____30min
time() + 900______15min
time() + 450______7.5 min
time() + 225______3.25 min
time() + 112.5____1.125 min
time() + 56.25____.625 = 37.5 sec.
The rest of your script goes here
ob_end_flush();
// Here you set the cookie
// The cookie is called logged_in and can be found
// in the directory that your browser keeps cookies.
setcookie('logged_in' , $cookieVal ,(time() + 3600)) or die('no cookie');
echo $_COOKIE['logged_in']
how to upload images and files php Upload Images to Webserver
HTML Form PHP Function
# UPLOAD FILE
function upload_file(){
echo '
what is php Explanation of PHP Basic Syntax --New to PHP
Php is a language that is very much like writing c. The best feature of PHP versus c is that it is designed pri
how to use dreamweaver Dreamweaver - WISIWIG
Dreamweaver is a tool that arguably could be called the industry standard for web design
. Dreamweaver, is an Adobe product that originally b
stop form spam captcha php PHP -- How to Protect My Email Form / Contact Form Against Spam Bots
Author: D.Shaun Morgan
Versions and Skill Level
PHP 5
php passing variables php Pass Variables from One Page to Another -- PHP
Author: D.Shaun Morgan
Tutorial Outline :
Passing PHP variables with $_

Leave a Comment
using-php-cookies-variables