Question

First timer on all fronts here. I've done my digging and I'm ready to post it. I can't seem to get my session variables to carry over. From what I've read, header(LOCATION:) can do some pretty wonky stuff and some code may not be done. session_start(); is at the top of every page. Heres page 1:

<?php
session_start();
include "/header.php";
$username = $_POST["user"];
$db = new SQLite3("../../database/login.db");
$password = md5($_POST["password"]);
$userquery = $db->querySingle("SELECT username FROM accounts WHERE username='$username';");
$passquery = $db->querySingle("SELECT password FROM accounts WHERE username='$username';");
$loggedin = false;

I call the session variable here on the same page (1):

if ($loggedin == true)
{
    $_SESSION['user'] = $username;
    header('LOCATION: ../test.php');
}

Then on the logged in page (2) the header references I have:

<?php session_start();?>
<?php include "header.php";?>
<html>
    <head>
        <link href="dashboard.css" rel="StyleSheet" type="text/css"/>
        <title>
             Dashboard
        </title>
        <h1>
            Dashboard
        </h1>
        <h2>
            Greetings: <span><?php echo $_SESSION['user'];?></span> Today's date: <span><?php $date = date("l,F,N,Y"); echo $date;?></span>

Any help would be appreciated. I feel like I'm missing something simple. Thanks everyone!

Was it helpful?

Solution

I FIGURED IT OUT!! So I'm using cloud9 IDE and the PHP.ini file in use doesn't permit sessions. Now what I had to do was create my own PHP.ini file in the root project folder. This ini file overrides the one that cloud 9 defaults to which is only readable. I hope this helps someone in the future!!!!!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top