I am setting the global variable once I validate the user, however when I try and access that global variable it comes back as null...
LOGIN.PHP code snip
if( Decrypt(odbc_result($rs_results,"password")) == $password){
session_register('g_user_id');
$g_user_id = odbc_result($rs_results,"user_id");
MAIN.PHP
print $g_user_id [value is null]
Any thoughts???
help with a global variable
Moderator: General Moderators
I looked at that page and tried to do it how he said and I still can not set the session variable.. here is the code.
LOGIN:
if( Decrypt(odbc_result($rs_results,"password")) == $password){
$_SESSION['user_id'] = print odbc_result($rs_results,"user_id");
header("Location: tabs.php"); // GOING TO TABS.PHP
print $_SESSION['user_id']; //THIS WORKS AND PRINTS USER ID
die();
TABS.PHP
<? session_start() ?>
<?
print "session global =".$_SESSION['user_id']; // PRINTS OUT NULL
?>
Can anyone explain please...?????
LOGIN:
if( Decrypt(odbc_result($rs_results,"password")) == $password){
$_SESSION['user_id'] = print odbc_result($rs_results,"user_id");
header("Location: tabs.php"); // GOING TO TABS.PHP
print $_SESSION['user_id']; //THIS WORKS AND PRINTS USER ID
die();
TABS.PHP
<? session_start() ?>
<?
print "session global =".$_SESSION['user_id']; // PRINTS OUT NULL
?>
Can anyone explain please...?????
Try this:
LOGIN:
TABS.PHP
LOGIN:
Code: Select all
<?php
session_start(); //put this at the top of the page
if( Decrypt(odbc_result($rs_results,"password")) == $password){
$_SESSION['user_id'] = print odbc_result($rs_results,"user_id");
header("Location: tabs.php");
print $_SESSION['user_id'];
die();
}
?>Code: Select all
<?php
session_start();
$userid = $_SESSION['user_id'];
echo "session global = $userid";
?>I have <? session start() ?> at the top already if you have AIM could you IM me and I could better describe my problem.. AIM: KICA5
Thanks for your help
Thanks for your help
DuFF wrote:Try this:
LOGIN:TABS.PHPCode: Select all
<?php session_start(); //put this at the top of the page if( Decrypt(odbc_result($rs_results,"password")) == $password){ $_SESSION['user_id'] = print odbc_result($rs_results,"user_id"); header("Location: tabs.php"); print $_SESSION['user_id']; die(); } ?>Code: Select all
<?php session_start(); $userid = $_SESSION['user_id']; echo "session global = $userid"; ?>