Cookies and Session - in Detail

How to set cookies?


variable - Name of the cookie variable
value - Value of the cookie variable
time - Expiry time;
Example: setcookie('Test',$i,time()+3600);

Test - cookie variable name
$i - value of the variable 'Test'
time()+3600 - Cookie will expire after one hour.

How to reset/destroy a cookie?

Reset a cookie by specifying expire time in the past:
Example: setcookie('Test',$i,time()-3600); // already expired time

Reset a cookie by specifying its name only
Example: setcookie('Test');

Default session time in php?

The default session time in php is until closing of browser.

How to get the value of current session id?

session_id() returns the session id for the current session.

No comments:

Providing tips to improve website quality, website speed, website design and website performance is the main objective of this blog. Improving website quality and website performance increases website traffic and page rank. Details on Web technologies, Quality website design, SEO concepts, Developer guides, and website related in IT industry.