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");
}

Recommended Answers

All 8 Replies

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.

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.

Simply the page that you want to show to public users, do not keep session check in such pages.

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

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.

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");

@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...

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.