Accessing variables from two different sessions?
I have integrated WHMCS and Drupal. However, when you go to Drupal and you print_r the SESSION, you see completely different information tha开发者_如何转开发n what you would do if you go to the WHMCS pages. So, my question is, how do I access the one's session, from the other one?
I need to access it, in order to see if the user is logged in or not.
The values you'll get depend on the session.name
directive in php.ini
. If you want them to be able to read each others', then set the same session.name
.
Or rather, session data will be loaded based on the identifier in the cookie with the same name as session.name
. This defaults to PHPSESSID
, but you can change it yourself.
You can set this at runtime using ini_set()
or session_name()
.
Drupal register its own session handling functions through session_set_save_handler()
during bootstrap (drupal_bootstrap()
). It also sets it own session mame in conf_init()
.
Because of the Drupal's handlers, restoring the WHMCS' session name before using standard PHP session will not work. PHP will use Drupal's hanlder to open, read, write, etc. session information. All you will get is the data for a wrong Drupal's session returned from sess_read()
when called by PHP.
One way to read WHMCS' session is to figure out how it is stored and to access it without using PHP's sessions functions.
Another way may be to undo what Drupal has done (changing session name and registering handlers) to restore default behaviors of PHP's session functions, read the WHMCS' session and restore Drupal's session name and handlers.
精彩评论