I have a javascript (jQuery) button inside a PHP file1 which calls a PHP file2. I want to modify a session variable at the PHP file2 and read the modification -the new value of the session variable- after getting back to the PHP file1. I try that but it does开发者_JAVA百科n't work. Did I miss something? Or it's not possible?
Guys, don't forget about session_start() or use session.auto_start = On in your php.ini. Without it session will not work.
file2.php:
session_start();
$_SESSION['something'] = 'value';
file1.php:
session_start();
var_dump($_SESSION['something']);
I could read it now after I changed something but I don't know why! I had to at the beginning of file1 I had this statement
$_SESSION['value'] = 1.5;
And I added a new value in file2. When I removed this statement from file1, I was able to get the value which is written in file2. Is it possible that file1 override file2 even though file2 is called inside file1?
HI ,
ok first session in file1 like $_SESSION['a'] = 1.5;
than when you move to file2
unset the session and than asign value to session variable like
unset($_SESSION['a']); $_SESSION['a'] = 1.5;
Hope this will be useful to you
精彩评论