sess_regenerate

5 session.inc sess_regenerate()
6 session.inc sess_regenerate()

Called when an anonymous user becomes authenticated or vice-versa.

2 calls to sess_regenerate()

File

includes/session.inc, line 126
User session handling functions.

Code

function sess_regenerate() {
  $old_session_id = session_id();

  // We code around http://bugs.php.net/bug.php?id=32802 by destroying
  // the session cookie by setting expiration in the past (a negative
  // value).  This issue only arises in PHP versions before 4.4.0,
  // regardless of the Drupal configuration.
  // TODO: remove this when we require at least PHP 4.4.0
  if (isset($_COOKIE[session_name()])) {
    setcookie(session_name(), '', time() - 42000, '/');
  }

  session_regenerate_id();

  db_query("UPDATE {sessions} SET sid = '%s' WHERE sid = '%s'", session_id(), $old_session_id);
}

Comments

How can I change this function?

I made a change like following:

function sess_regenerate() {
$old_session_id = session_id();

if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time() - 42000, '/');
}

session_regenerate_id();
db_query("UPDATE {sessions} SET sid = '%s' WHERE sid = '%s'", session_id(),$old_session_id);
db_query("UPDATE {sessions} SET sid_old = '%s' WHERE sid = '%s'", $old_session_id,session_id());
}

how can I achieve this change by hook?

Login or register to post comments