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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.