Link to home
Start Free TrialLog in
Avatar of CONDOI
CONDOI

asked on

Do if with the session.

if  "$user" = "$user"
{
      echo "<p>still in the secure area.</p>";
      include ("secure.php");
      exit;
}

else

echo "sign out already";
Avatar of ldbkutty
ldbkutty
Flag of India image

Do you want something like this :

<?php
   
    session_start();
    if ( isset( $_SESSION["user"] ) && !empty( $_SESSION["user"] ) )
    {
        echo "<p>still in the secure area.</p>";
        include ( "secure.php" );
        exit();
    }
    else
        echo "sign out already";

?>
in order to be able to check your session vars you must call session_start() function in every page prior to start checking session vars existence. you can put the call in your header to be absolved of this worry, since you must include the header on every page of the site. the approach presented in the post above is ok, i am using a similar one too.

pls check out my post on this thread
https://www.experts-exchange.com/questions/21332607/login-script.html

kind regards,
mircea
ASKER CERTIFIED SOLUTION
Avatar of 4Rabbits
4Rabbits

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
Split between 4Rabbits, msimion and ldbkutty

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

- Neester -
EE Cleanup Volunteer
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
Accept 4Rabbits solution

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

- Neester -
EE Cleanup Volunteer