Forum Moderators: coopster

Message Too Old, No Replies

$ SESSION display issue

         

Modern Merlin

12:42 am on Aug 21, 2008 (gmt 0)

10+ Year Member



I am using the following code to pass a global variable in PHP

<?php
session_start();
$_SESSION['user'];
$user = $_SESSION['user'];
echo "&varUser=$user&";
?>

It works in IE and in FireFox on every computer I have tried it on.

However, I have a friend who tried to load it on his using FireFox and when he goes to the page it is NOT passing the variable. It echos &varUser=&

This is the code I am using to set that variable:


if($numrows > 0 && $numrows2 > 0){
//Creating page variables
$pageold = ("http://www.domainhere/game.php");
$pageold.= header("Location:".$pageold);
header($_SESSION[$user]);
exit;//abort php script
}

As I said this works on ALL the computers I have tried it on but his in FireFox. He has the most updated version of FireFox and of the flash plugin.

I am so lost right now. I have no idea what to look for or even where to start looking. Any help would be much appreciated!

MM

MattAU

2:11 am on Aug 21, 2008 (gmt 0)

10+ Year Member



I can't see where you're setting the session variable. I think you've got sessions and headers mixed up a bit. Not really related, but header() doesn't return anything so you can't append it to $pageold.

Try this:

//assumes you've already created the session
if($numrows > 0 && $numrows2 > 0){
//Creating page variables
$_SESSION['user'] = $user;
$pageold = "http://www.domainhere/game.php";
header("Location: ".$pageold); // Note the space between Location: & $pageold. Not having the space could be causing browser problems.
exit;//abort php script
}

eeek

4:59 am on Aug 21, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



$_SESSION['user'];

What is that supposed to do?

Modern Merlin

5:17 am on Aug 21, 2008 (gmt 0)

10+ Year Member



Thanks so much! This worked perfectly! And I was setting it at the start of the page, but I wasn't doing it right. I also forgot that it was "global", there for I didnt need to append it LOL

Thanks again!

MM