Question : -
How create define session variable & what is cookies how to set cookies.
Session are temporary storage variable, by using
session you can get variable value in another file .
Session_start();
Session[‘ab’] = ‘hello’;
Session_close();
Session variables are stored in associative array called $_SESSION[]. These variables can be accessed during lifetime of a session.
<?php
session_start();
if( isset(
$_SESSION['ab'] ) ) {
$_SESSION['ab']
-= 1;
}else {
$_SESSION['ab']
= 1;
}
$msg = "value
of ab is ". $_SESSION['ab'];
$msg .= "in
this session.";
?>
<html>
<head>
<title>define
session</title>
</head>
<body>
<?php echo ( $msg ); ?>
</body>
</html>
Similarly use session_destroy() destroy current session.
& session_close() use to close started session.
Let us see cookies , as similar to session cookies are
text file to store user information.
An alert or popup message most of site are uses, eg : we
are using your cookies to store information for better performance.
<?php
setcookie("name", "mayor abc", time()+1600, "/","", 0);
setcookie("age", "34", time()+1600, "/", "", 0);
?>
<html>
<head>
<title>how to define Cookies with PHP</title>
</head>
<body>
<?php echo "hi setting cookies"?>
</body>
</html>
In next session we see more detail.
Thanks for viewing blog send comment in case any query.
THANK YOU FOR THE INFORMATION
ReplyDeletePLEASE VISIT US
Website Development in Bangalore