Session Variable Does Not Get Updated Within Javascript Code
Solution 1:
That's because when the delete_define.php was loading the Session var was one, then it's become another, but in you JS stored previous value.
You should store session var into JS var, and then in JS in delete_now.php reset it with the fresh value.
How to refresh value from frame and other situations
Add to first php file's JS something like:
var session_var = '<?phpecho$_SESSION['my_session']; ?>';
And then in your delete_now.php's JS:
parent.session_var = '<?phpecho$_SESSION['my_session']; ?>';
And change function my_func to alert session_var JS variable.
Think so...
Explanation:
Then result page js will be:
function my_func_2(){
alert("my_func_2 = 13513513513513");
returntrue;
}
So when you call it, whatever is in the $_SESSION is, there will be old, static value.
Overall process description:
- Load delete_define.php
- Javascript var, containing actual filename initialized
- From submits
- Script delete_now.php is runing
- Javascript var in main window refreshes
- You call my_func_2() which use you global JS var, containing fresh filename.
Solution 2:
you have assigned random number, so based on the order you run the page will give alert, if you start from delete_now.php two consecutive alerts will be same . first assign some static value and then check
Post a Comment for "Session Variable Does Not Get Updated Within Javascript Code"