我如何需要一个函数的会话

i have in my sandbox many of function, some of the function are public, and other's i want them to be only for website member's. this is an example for a function i want it to be for website members only

function get_page ($dbc, $pg) {

// the database connection, our query
        $q = "SELECT * FROM pages WHERE name = '$pg' AND status = 1 LIMIT 1";
        $r = mysqli_query($dbc, $q);
        $page = mysqli_fetch_assoc($r);

        echo '<div class=entry>';
            echo '<h1>'.$page['title'].'</h1>';
            echo '<div class="content_body">'.$page['body'].'</div>';   
        echo '</div>';
}

is there any way to do that?

"how i require session for a function"

Use the following, as an example:

if(!isset($_SESSION['session_name'])){ die(); } 

and to include session_start(); inside all of the files used, and at the * top.
(* Depending on the condition).

For more information on sessions, visit the following:

Footnotes:

Should you be faced with an headers already sent... error message later on, you can make use of ob_start(); placed above session_start().

For example:

<?php
ob_start();
session_start();
// code

Your question is really not clear. You can use something like:

// Private function for members
function privateFunction($isMember=false){

    if($isMember){
      // DO your things
    }
    else{
      callError();
    }
}

Or make use of PHP Session variables directly into your function ?