Hi there,
When I first discovered session vars, I fell in love. Now, that the site I have been working on for 3
months has been launched, I'm not so sure. Here is my problem.
The site uses sessions throughout. On every page, the following is contained in the beginning any given
script:
session_start();
include ('/path/session.lib');
Every time I want to register or delete a var, I use one of the following functions.
function set_session_var($name,$value) {
session_register ($name);
$GLOBALS[$name] = $value;
}
function del_session_var($name) {
session_unregister($name);
unset($GLOBALS[$name]);
}
So if I want to handle sessions in my script, I do:
del_session_var("ses_id");
set_session_var("ses_id","123");
echo $GLOBALS['ses_id'];
On my computer (which is just a client), this approach is fine. I have no problem displaying my session
vars, deleting them or creating them in IE. However, on other computers in our office, this is not the
case, and I myself, also have problem with Netscape. I have checked the security settings, and they are
identical.
I have a feeling that there might be some kind of problem with the scope of the session var. On
http://www.php.net/manual/ref.session.php one fellow suggested adding a
global $name;
in the set_session_var($name,$value) function, but that does not seem to work for me. I specifically add
the session var to the GLOBALS array, since I experienced problems with displaying vars immediatly, if
they weren't added directly.
Is my approach reasonable? Are there any obvious flaws?
Any ideas as to why the above solution is flawed would be greatly appreciated.
Sincerely,
Jens