5

I am using Drupal 7 and am looking for a hook which is called before any session is created.

According to the the API page, hook_boot() is called after DRUPAL_BOOTSTRAP_SESSION. The link is for Drupal 6, I assume nothing changed in Drupal 7.

Is there a hook I can call which is called before any session is created?

  • What do you want to do before sessions are created? Why can't you do this in hook_boot()? – Eugene Fidelin Nov 13 '12 at 15:32
  • I have a module which needs to be manage the session. – rexposadas Nov 14 '12 at 0:35
  • Take look at these modules drupal.org/node/597706 how they manage sessions – Eugene Fidelin Nov 14 '12 at 8:52
2

If you wish to manage the session as mentioned in your comment, you can completely replace the default session handling by setting the variable session_inc to the path of an include file that defines the functions expected by Drupal.

In your settings.php file:

$conf['session_inc'] = 'sites/all/modules/my_session_handler/session.inc';

And in session.inc you will need to implement the following functions:

You may want to start by copying Drupal's default session.inc and modifying it to suit your needs. Keep in mind that any of the functions in the default session.inc starting with an underscore are considered private, and not necessary to implement in your custom session.inc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.