Problem with Session Variables

software development


My new site (this has PHP Version 5.2.3) is having a problem with passing session variables to subsequent pages. I have an older site ( that uses PHP Version 4.4.7) that seems to work fine with the session variables declared the same manner.

An example of my creating the session variables is given below:

$GLOBALS[‘Var’] = $Var;

So, whereas this seems to work with the PHP Version 4.4.7 site, its not with the PHP Version 5.2.3 site. Any suggestions on what i might need to do to get my new site carrying session variables?

Incidentally, my session settings are as follows:

Session Support enabled
Registered save handlers files user sqlite
Registered serializer handlers php php_binary

Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 Off Off
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_httponly Off Off
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.hash_bits_per_character 5 5
session.hash_function 0 0 PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /tmp /tmp
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid 0 0


Read the PHP manual on session_register() and you will see that you shouldn’t use it with DreamHost’s PHP5 setup. For one thing, register_globals() is disabled.

Max discount on any plan with promocode SCJESSEYTOTAL


It seems to me that you’re not working around the problem really. If the GLOBALS scope isn’t enabled, you won’t be able to do what you’re trying to do here because you’re still referencing GLOBALS when making the assignment on line 2.

Basically what i think you’ll need to do is replace the code in question like this:

[quote]replace: $GLOBALS[‘Var’] = $Var;
with $_SESSION[‘Var’] = $Var;
Maybe I am a little confused about the snippet you pasted, but that’s what comes to my mind when I look at it. Let me know if I am just misunderstanding you or something.