Page 1 of 1

$_SESSION Problem????

Posted: Mon Nov 20, 2006 10:50 pm
by vbora85
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi all, I have problem with the $_SESSION variable.
Check this out:

temp1.php

Code: Select all

<?php
session_start();
funtion test1()
{
$_SESSION["temp"]="a";
//then direct to the file temp2.php
}

function test2()
{
$_SESSION["temp"]="b";
//then direct to file temp2.php
}
?>

temp2.php

Code: Select all

<?php
session_start();
echo $SESSION["temp"];
?>


In the process, I firstly call out the file temp1.php. Then within the function test1(), i direct to the file temp2.php. After finishing runing the file temp2.php, it continues its process in file temp1.php, runing function test2(). Again the function test2() also directs to the file temp2.php. Suprisingly, here is the result::::


bb


It should be like this:


ab



So, why the result is "bb"?? It should be "ab"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Any explaination!!!!!!!!!!!!!!!!


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Nov 20, 2006 11:15 pm
by feyd
What's with all the exclamation marks?

Can you post the real code? What you've posted won't parse in PHP.

Posted: Tue Nov 21, 2006 8:02 am
by ferreira.jorge

Code: Select all

<?php
session_start();
echo $SESSION["temp"];
?>
You are trying to echo $_SESSION and you've got $SESSION.
Try change it.
Another thing is that test1() and test2() are functions and I can't see where you call them in your code.
Hope this helps...