Monday, 2 February 2015

Session

Session stored values in  variables, and from this variables we can fetch data on multiple pages .
to create session we should start it first example :
<!DOCTYPE html>

<html>
<body>

<?php
//its start session
session_start();

//set variable for session
$_SESSION['mysession']='php-guides';
?>

<p style="color:red">Session Value=<?php print($_SESSION['mysession']);?></p>

</body>
</html>

Output Print:


Sunday, 1 February 2015

Update & Delete Cookies

If want to update & delete single cookie we can use the below methods ref from previous example

http://php-guidelines.blogspot.com/2015/02/cookies.html:


Delete Cookie :

setcookie("your_user", "", time() - 3600);


Update Cookie:

if user want to update cookie then set again cookie using setcookie method example:

$cookie_name = "your_user";
$cookie_value = "new value";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30)); // 86400 = 1 day