Reply to session_start issue

Your name:

Reply:


Posted by paladin.rithe@gmail.com on 10/09/06 18:28

I'm running into an issue with session_start(). I see that you can't
run it twice, otherwise it causes an issue. That's fine, and makes
sense. I also saw some ideas on how to get around this if you need to
run it more than once, and I get those as well, but none are working
for me.
Here's a mockup of what I have:

index.php
info.php
lib/common.php
lib/output.php

index.php
<?php
require_once('lib/common.php');
require_once('lib/output.php');

sessionStart();

runout();
?>

info.php
<?php
require_once('lib/common.php');
require_once('lib/output.php');

sessionStart();

output("Hello World");

outputStop();
?>

lib/common.php
<?php
ob_start();

function startSession()
{
if(!isset($_SESSION))
{
session_start();
}
}

?>

lib/output.php
<?php
require_once('lib/common.php');
sessionStart();

function output($out)
{
$_SESSION['output'] .= $out;
}

function outputStop()
{
header("Location: index.php");
}

function outrun()
{
echo $_SESSION['output'];
}
?>

As near as I can tell (I have other session variables that this is
happening to) the sessionStart function in output.php is interfearing
with the one in info.php. When I comment the one from output.php out,
my scripts run fine, but with it I get errors, usually something about
a class not being fully defined (from another lib/*.php file).
Can anyone see anything wrong with what I'm doing? The only reason I'm
doing it this way is so users can't use the back button (I'm working on
a game, and would rather not have people hit back to try and get around
stuff, but that would be to their detrememnt probably anyway) so all
the output is done by index.php (in this example at least). I am
storing the output info in the session variable so index.php can
actually use it.
Of course, on the other hand, if someone has an idea for getting around
the "Back" issue without doing it this way, I'm open to suggestions.
Although I'd probably have to run stuff through a filter of some sort
still, just for security purposes, but that's another story.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация