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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -