...

View Full Version : Sessions Don't Work



CanHasPotato
08-24-2009, 02:19 PM
On my website I have a big IFrame which all my content is viewed in. I also have a search script, which I want to load the results into the IFrame. I've been using GET to do it, but I want to move to sessions for more safety and it seems not to work. I've shown both of my scripts below, hope you can help. :D
The page with the big IFrame (mark.php or / (with .htaccess)):


<?php
if (isset($_GET['p']) || isset($_POST['p']) || isset($_SESSION['p'])) {
if (isset($_GET['p'])) {
$p = $_GET['p'];
}
elseif (isset($_SESSION['p'])) {
$p = $_SESSION['p'];
unset($_SESSION['p']);
}
else {
$p = $_POST['p'];
}
}
elseif (!isset($_GET['p']) && !isset($_GET['p']) && !isset($p) && !isset($_SESSION['p'])) {
$p = "news.php";
}
?>



<iframe id="content" src="http://harsh.bplaced.com/<?php echo $p; ?>" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none"></iframe>

The search page (search.php):


<?php
session_start();
$_SESSION['p'] = "search_.php?query=" . $_POST['query'];

header("Location: http://www.harsh.bplaced.com/");
?>

Fou-Lu
08-24-2009, 02:23 PM
Frames are a pain.
You'll need to force you're write if I'm not mistaken, though it has been a looooooonnnnggg time since I've used the session extension. Look at session_write_close()/session_commit() (http://php.ca/manual/en/function.session-write-close.php).

CanHasPotato
08-24-2009, 02:33 PM
Frames are a pain.
You'll need to force you're write if I'm not mistaken, though it has been a looooooonnnnggg time since I've used the session extension. Look at session_write_close()/session_commit() (http://php.ca/manual/en/function.session-write-close.php).

Sorry to bug you, but I've tried placing it all over the code but I still can't seem to get it to work. I might just go back to GETing the the variable.

<?php
session_start();
$_SESSION['p'] = "search_.php?query=" . $_POST['query'];
session_write_close();
header("Location: http://www.harsh.bplaced.com/");
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum