Jump to content

[SOLVED] Additional but Different Session Madness


blackcell

Recommended Posts

Hello,

I have been reading for the past day on sessions and I can't figure out what I am doing wrong. 

 

From my reading I understand that in order to make session variables available from one page to the next is:

<?php
//index.php
session_start();
$_SESSION[0] = "something123";


//seperate.php
session_start();
echo $_SESSION[0];

//Should print "something123"
?>

 

I am not getting the desired outcome.

I am including a bit of my code. Basically I have something called engine.core.php and that will have everything that needs to be loaded on every page like session_start() and including files that need to be and such.

 

<?php
//engine.core.php snippet
session_start();

//constants.php snippet
$tier1 = -1;
$tier2 = -1;
define("SID",$tier1++);
define("SYS",$tier1++);
    define("SYS_VER",$tier2++);
    define("SYS_ROOT",$tier2++);
    define("SYS_PAGE",$tier2++);
    define("SYS_COMMAND",$tier2++);
define("USER",$tier1++);
    define("USER_ID",$tier2++);


//validate.inc.php snippet
//This is included if the person is not on the login, or register page (attempting to go past the login via link)
if($_SESSION[sYSID] == ""){
    die("Dead [LINK TO REDIRECT EVENTUALLY]");
}

//login.php snippet
require("engine.core.php")//session_start() 
   // .
   // .
   // .
   // . User logs in, password is checked, and user unique id is retrieved from database to use a a key for all other info
   // . The queried number is saved as $queryID.  I have tested this and for sure retrieving a number so the mistake is not on my query.
   $_SESSION[sID] = $queryID;

?>

 

I get through the login process and go to my next screen where validate.php will be included and it kills me. I echo the

<?php $_SESSION[sID] ?>

and it is empty?

 

Can anybody offer any advice or suggestions on what is happening and how I need to pass Session vars?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.