php - how i require session for a function -


i have in sandbox many of function, of function public, , other's want them website member's. example function want website members only

function get_page ($dbc, $pg) {  // database connection, our query         $q = "select * pages name = '$pg' , 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 way that?

"how require session function"

use following, example:

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

and include session_start(); inside of files used, , @ * top.
(* depending on condition).

for more information on sessions, visit following:

footnotes:

should faced headers sent... error message later on, can make use of ob_start(); placed above session_start().

for example:

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

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -