Dear all,
I am trying to get the following code functioning in a much more complex situation as this example.
I wish to set the session variable in a function that is in a separate php file called with include : )
If I test it without this 'include' my code will be working:
(I know that for the real thing using $_SESSION[] is better, but it does not solve my problem)
File test1.php
File test3.php
This will output: 75 points for me
Now the problem (please keep in mind that due to some factors I can not call the session_register only in test2.php and it must be set and used in test1.php)
File test1.php
File test2.php
File test3.php
I expected the same outcome, but instead the $testing variable has not registered?!
Anyone who can help?
Many thanks
JR
I am trying to get the following code functioning in a much more complex situation as this example.
I wish to set the session variable in a function that is in a separate php file called with include : )
If I test it without this 'include' my code will be working:
(I know that for the real thing using $_SESSION[] is better, but it does not solve my problem)
File test1.php
Code:
<?
session_start();
if(!session_is_registered('testing'))
{
session_register('testing');
}
?>
<A HREF="test3.php"
onMouseOver="window.status='hi you';return true"
onclick="<?=$testing=75?>">HTML Goodies</A>
<?
?>
File test3.php
Code:
<?php
session_start();
echo $testing." points for me";
session_destroy();
?>
This will output: 75 points for me
Now the problem (please keep in mind that due to some factors I can not call the session_register only in test2.php and it must be set and used in test1.php)
File test1.php
Code:
<?
include("test2.php");
session_start();
if(!session_is_registered('testing'))
{
session_register('testing');
}
testsession();
?>
File test2.php
Code:
<?
function testsession()
{
?>
<A HREF="test3.php"
onMouseOver="window.status='hi you';return true"
onclick="<?=$testing=75?>">HTML Goodies</A>
<?
}
?>
File test3.php
Code:
<?
session_start();
echo $testing." points for me";
session_destroy();
?>
I expected the same outcome, but instead the $testing variable has not registered?!
Anyone who can help?
Many thanks
JR