0

Actually I want to show the read more button if the session is not stored and if the session is stored then it is redirected to research.php..

                         if (!isset($_SESSION['user'])) {






                      ?>                         

<a href="#" class="ec-colorhover" style="color: #f26530" data-toggle="modal" data-target="#myModal1">Read More <i class="fa fa-angle-double-right"></i></a></p>                 


                        <?php
                        }

                        else
                        {
                        ?>
                          <a href="research.php" class="ec-colorhover" style="color: #f26530">Read More <i class="fa fa-angle-double-right"></i></a></p>

3 Answers3

1

For your question you asked when browser is closed session gets destroyed automatically. So next time when you open the page it will contain 1st link

Exception
  • 789
  • 4
  • 18
0

you can try this way Destroy PHP Session on closing

session_set_cookie_params(0);
session_start();

or

By reducing the session timeout, shown here How to change the session timeout in PHP?

Community
  • 1
  • 1
Samrat Das
  • 1,781
  • 1
  • 21
  • 33
0

Use this code.

<?php
session_start();                //session starting
if (isset($_SESSION['user']))   //if session variable user is set?
{
header ('Location: research.php');  //go to research.php
}
else        //else show button
{
?>
<input type="button" value="Readmore" />    
<?php
}
?>

Note: But this code should be on top of every code.

And use unset($_SESSION['user']); to unset a specific session variable. Here it will unset variable user.

Subin Thomas
  • 1,408
  • 10
  • 19