php - $_SESSION is not working. something wrong? -


i know there similar question believe problem file different.code follows:

<?php require_once 'resources/core.inc.php'; require_once 'resources/connect.inc.php'; /*  * retreive posts post_table , populate them below. */?> <html>  <head><title>view posts.</title>     <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0 , maximum-scale=1">     <link href='http://fonts.googleapis.com/css?family=indie+flower|yanone+kaffeesatz' rel='stylesheet' type='text/css'>     <link rel="stylesheet" href="resources/viewposts.css"></head> <body><?php if(isset($session['s_id'])||isset($_session['f_id'])){    $result = $conn->prepare("select * post_table order_by p_id desc");    $result->execute();    $row = $result->fetchall();    foreach($row $rows){      echo $rows['p_id'].'<br>';     echo $rows['u_id'].'<br>';     echo $rows['u_name'].'<br>';     echo $rows['p_title'].'<br>';     echo $rows['p_body'].'<br><hr>';     }    }else{ echo '<center><h1 id="logmsg">please log in.</h1></center>';} ?></body> 

the problem session set echoing "please log in". if use

<?php    //faculty login page.  //if logged in show upload option/show login option.    require_once 'resources/core.inc.php';   require_once 'resources/connect.inc.php';     if(isset($_session['f_id'])&&!empty($_session['f_id'])){     echo 'faculty';     }elseif(isset($_session['s_id'])&&!empty($_session['s_id'])){    echo 'student';    }       else{   echo 'log in now.';    }    ?> 

it says logged in.

to elaborate on comment, change line...

if(isset($session['s_id'])||isset($_session['f_id'])){ 

to...

if (isset($_session['s_id']) || isset($_session['f_id'])) { 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -