php Session Variables in Header Redirect not working

Status
Not open for further replies.

Jondoe0069

New member
Mar 21, 2007
1,317
19
0
Estados Unidos
I'm trying to track keywords using session variables. I have no problem printing these variables on any page, but when I try to call them in a header redirect, they don't show. I've read and apparently this is a bug in php? Or maybe it was and it got fixed.

Any advice on how to get my session variables into the URL in my header redirect?


Here is what I have on the landing pages-

PHP:
<?php
session_start();
session_register ("YSMRAW");
session_register ("YSMKEY");
session_register ("OVKEY");
session_register ("OVRAW");
session_register ("KEYWORD");

$HTTP_SESSION_VARS ["YSMRAW"] = $_GET["YSMRAW"];
$HTTP_SESSION_VARS ["YSMKEY"] = $_GET["YSMKEY"];    
$HTTP_SESSION_VARS ["OVRAw"] = $_GET["OVRAW"];
$HTTP_SESSION_VARS ["OVKEY"] = $_GET["OVKEY"];
$HTTP_SESSION_VARS ["KEYWORD"] = $_GET["KEYWORD"];

?>

and this is my redirect:

PHP:
<?php

session_start();

header( 'Location: http://x.azjmp.com/xxxx?sub=' . $_SESSION['YSMRAW'] . 'X' . $_SESSION['OVRAW'] . 'X' . $_SESSION['KEYWORD'] ) ;

?>

Thanks!
 


Edit:

This is what I have on all the landing pages-

Code:
<?php

if (isset($_GET["YSMRAW"]) or isset($_GET["YSMKEY"]) or isset($_GET["OVKEY"]) or isset($_GET["OVRAW"]) or isset($_GET["KEYWORD"]))
{
session_start();
session_register ("YSMRAW");
session_register ("YSMKEY");
session_register ("OVKEY");
session_register ("OVRAW");
session_register ("KEYWORD");

$HTTP_SESSION_VARS ["YSMRAW"] = $_GET["YSMRAW"];
$HTTP_SESSION_VARS ["YSMKEY"] = $_GET["YSMKEY"];    
$HTTP_SESSION_VARS ["OVRAW"] = $_GET["OVRAW"];
$HTTP_SESSION_VARS ["OVKEY"] = $_GET["OVKEY"];
$HTTP_SESSION_VARS ["KEYWORD"] = $_GET["KEYWORD"];
}
else
{
session_start();
}

?>
 
This seemed to do the trick...

Code:
<?php

session_start();

$YSMRAW = $_SESSION['YSMRAW'];
$OVRAW = $_SESSION['OVRAW'];
$KEYWORD = $_SESSION['KEYWORD'];

header( 'Location: http://x.azjmp.com/xxxxx?sub=' . $YSMRAW . 'X' . $OVRAW . 'X' . $KEYWORD ) ;


?>
 
Hmm, what I'd like to know is why that made a difference? Shouldn't $YSMRAW be the same exact thing as the return value of $_SESSION['YSMRAW']?
 
I've noticed a similar problem to that, and it doesn't make sense, because like Darin says, there's no difference. It has to be an error in the syntax somehow, but I don't see it.
 
ahh, i see

'Location: hxxp://x.azjmp.com/xxxx?sub=' . $_SESSION['YSMRAW'] . 'X' . $_SESSION['OVRAW'] . 'X' . $_SESSION['KEYWORD'] ) ;

It's a problem with double and single quotes. The string ends at sub=' and it redirects, leaving off the rest.
 
Makes sense. I figured- so I just picked up the variables and added them to the URL. I just thought maybe that was a no-no since it's a redirect, but it doesn't seem to slow it down at all.
 
ahh, i see

'Location: hxxp://x.azjmp.com/xxxx?sub=' . $_SESSION['YSMRAW'] . 'X' . $_SESSION['OVRAW'] . 'X' . $_SESSION['KEYWORD'] ) ;

It's a problem with double and single quotes. The string ends at sub=' and it redirects, leaving off the rest.

Hmm I think almost right. I dont know if it makes any difference :D . It cannot end at sub=' because after sub=' you have a dot(.) meaning that it will connect it with the next string. My opinion is that it stops at $_SESSION['YSMRAW'
 
Status
Not open for further replies.