03-Apr-2023
.
Admin
Hi guys,
Today i will explained how to session work in without Browser Cookies in php . This example is so easy to use in php. THis example to i am increament to the session id in 3 time and then later restart the session start in php.
This exampel to i am only use the session not using to the browser cookies in php.
So let's start to the example.
Example :
form.php
<?php
ini_set('session.use_cookies', '0');
ini_set('session.use_only_cookies', 0);
ini_set('session.use_trans_sid', 1);
session_start();
?>
<p><b>Php Session Work Without Browser Cookies Example</b></p>
<?php
if(!isset($_SESSION['value'])){
echo("<p>Session Is Empty</>>\n");
$_SESSION['value'] = 0;
}else if($_SESSION['value'] < 3){
$_SESSION['value'] = $_SESSION['value'] + 1;
echo("<p>Added one \$_SESSION['value']=".$_SESSION['value']."</p>\n");
}else{
session_destroy();
session_start();
echo("<p>Session Restarted</p>\n");
}
?>
<p><a href="nocookies.php">Click This Link</a></p>
<p>
<form action="nocookies.php" method="POST">
<input type="submit" name="Click" value="Click Submit Button">
</form>
<p>Our Session Id: <?php echo(session_id()); ?></p>
</p>
<?php
print_r($_SESSION);
?>
now you can check your own.
i hope it can help you...
#PHP 8
#PHP