0

I want to be able to show some .php files before the user logs in
I know that the reason we do the session is for ones who are users to see the files but is it possible.
I have included the file that connects to teh database

session_start();
$session_uid=$_SESSION['uid']; 
if(!empty($session_uid))
{
header("location:index.php");
}
4
Contributors
8
Replies
51
Views
3 Years
Discussion Span
Last Post by SimonIoa
0

I am not sure, if this is want you want

session_start();

if(!isset($_SESSION['uid'] || $_SESSION['uid'] == ''){

    ## session don't exist or not set
    ## do what you need to do.
}

or alternatively we can do the positive

session_start();

if(isset($_SESSION['uid']){

    ## redirect to the page for logged in users

    }

    else{

        ## show them the page for non-logged in users

        }

please limit your usage of !empty or empty on session. Only in this occassion it is not 100% appropriate.

0

Are you asking to show data in the session before you enter the data?

I want to be able to show some .php files before the user logs in
I know that the reason we do the session is for ones who are users to see the files but is it possible.

0

Wronglly put. Basically all i want to show is the footer. The one that shows User Agreement, Terms Of Use and Privacy Policy pages. For the guest/user to read them before signing up. I am not trying to show any data from the database. The footer is shown after the user logs in but not on the welcome page (log page).

So, i am thinking that the session has nothing to do.
although i tried this as Veedeoo suggested

<?php
if(isset($session_uid))
{
echo 'ss';
}
else
{
include_once 'block_footer.php';
} 
?>

The url of the page etc Privacy Police is shown but when i press it remains on the welcome page

0

It seems t me that you can't use the session like you want. Can you just put a link to what you want and use that to create the session? You could have people agree to the terms of use and then, using that information, create your session.

if (isset($terms_of_use))
{
session_start();
echo 'ss';}

More of a question than anything.

0

this is the session.php

 <?php
$session_uid=$_SESSION['uid']; 
if(!empty($session_uid))
{
    $uid=$session_uid;
    $login='1';
}
else
{
    $url=$base_url.'login.php';
    header("location:$url");
}
?>

and wht is this?

ob_start("ob_gzhandler");

0

@Simonloa,

I highly recommend doing this. If you want to use the rest of your codes.

 if(isset($_SESSION['uid'])  && (!empty($_SESSION['uid'])){

     $uid=$session_uid;
        $login='1';
}

else{

       $url=$base_url.'login.php';
            header("location:$url");
}  

and for the ob_start("ob_gzhandler")

you can read all about it here...

0

Still the same Veedeoo.... Thanks for the link about ob_start i understand it.
Is there anything else i can do with login? Do you want me to send you anything else?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.