Thanks for the hint. I didn&#39;t know about <a href="http://api.drupal.org/api/function/user_external_login/6" target="_blank">user_external_login.</a> <br><br>Unfortunately it does not allow me to start a new session and call $_SESSION[LOGIN_AS_DIFFERENT_USER] = TRUE;. This line is very important, because later on it tells ip_login not to do an autologin but let the user login as a different user.<br>
<br>Are there some more things to think about?<br>Best Regards<br>Ernst<br><br><br><br><div class="gmail_quote">2010/2/8 Brian Vuyk <span dir="ltr">&lt;<a href="mailto:brian@brianvuyk.com">brian@brianvuyk.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


  

<div bgcolor="#ffffff" text="#000000">
Is it possible this could be simplified somewhat by using
user_external_login()?<br>
<br>
<a href="http://api.drupal.org/api/function/user_external_login/6" target="_blank">http://api.drupal.org/api/function/user_external_login/6</a><div><div></div><div class="h5"><br>
<br>
Ernst Plüss wrote:
<blockquote type="cite">Hi drupal friends<br>
  <br>
I&#39;ve written a patch for the ip_login module. It extends the module
with the possiblity to have a &quot;login as an other user&quot; link.<br>
  <br>
Basically it does the following things:<br>
  <ol>
    <li>Logs out the current user.</li>
    <li>Makes sure ip_login does not straight login again.</li>
    <li>Shows the user login screen.</li>
  </ol>
My code works, but I&#39;m not 100% sure whether it&#39;s save to code it like
that. Could someone have an I on it?<br>
  <br>
  <br>
  <font face="monospace" size="4"><font color="#0000ff">/**</font><br>
  <font color="#0000ff"> * Logs the current user out and start new
session.</font><br>
  <font color="#0000ff"> *</font><br>
  <font color="#0000ff"> * Most of the code taken from user_logout()
and _drupal_bootstrap().</font><br>
  <font color="#0000ff"> */</font><br>
  <font color="#a020f0">function</font> ip_login_as_different_user<font color="#6a5acd">()</font> <font color="#6a5acd">{</font><br>
  <font color="#2e8b57"><b>global</b></font> <font color="#804040"><b>$</b></font><font color="#008080">user</font>;<br>
  <br>
  watchdog<font color="#6a5acd">(</font>&#39;<font color="#ff00ff">user</font>&#39;,
&#39;<font color="#ff00ff">Session closed for %name.</font>&#39;, <font color="#2e8b57"><b>array</b></font><font color="#6a5acd">(</font>&#39;<font color="#ff00ff">%name</font>&#39; <font color="#804040"><b>=</b></font><font color="#804040"><b>&gt;</b></font> <font color="#804040"><b>$</b></font><font color="#008080">user</font><font color="#2e8b57"><b>-&gt;</b></font><font color="#008080">name</font><font color="#6a5acd">))</font>;<br>

  <br>
  <font color="#0000ff">// Destroy the current session:</font><br>
  <font color="#008080">session_destroy</font><font color="#6a5acd">()</font>;<br>
  <font color="#0000ff">// Only variables can be passed by reference
workaround.</font><br>
  <font color="#804040"><b>$</b></font><font color="#008080">null</font> <font color="#804040"><b>=</b></font> <font color="#2e8b57"><b>NULL</b></font>;<br>
  user_module_invoke<font color="#6a5acd">(</font>&#39;<font color="#ff00ff">logout</font>&#39;,
  <font color="#804040"><b>$</b></font><font color="#008080">null</font>,
  <font color="#804040"><b>$</b></font><font color="#008080">user</font><font color="#6a5acd">)</font>;<br>
  <br>
  <font color="#0000ff">// Load the anonymous user</font><br>
  <font color="#804040"><b>$</b></font><font color="#008080">user</font> <font color="#804040"><b>=</b></font> drupal_anonymous_user<font color="#6a5acd">()</font>;<br>
  <br>
  <font color="#a020f0">require_once</font> variable_get<font color="#6a5acd">(</font>&#39;<font color="#ff00ff">session_inc</font>&#39;, &#39;<font color="#ff00ff">./includes/session.inc</font>&#39;<font color="#6a5acd">)</font>;<br>

  <font color="#008080">session_set_save_handler</font><font color="#6a5acd">(</font>&#39;<font color="#ff00ff">sess_open</font>&#39;, &#39;<font color="#ff00ff">sess_close</font>&#39;, &#39;<font color="#ff00ff">sess_read</font>&#39;,
&#39;<font color="#ff00ff">sess_write</font>&#39;, &#39;<font color="#ff00ff">sess_destroy_sid</font>&#39;,
&#39;<font color="#ff00ff">sess_gc</font>&#39;<font color="#6a5acd">)</font>;<br>
  <font color="#008080">session_start</font><font color="#6a5acd">()</font>;<br>
  <br>
  <font color="#804040"><b>$</b></font><font color="#008080">_SESSION</font><font color="#6a5acd">[</font>LOGIN_AS_DIFFERENT_USER<font color="#6a5acd">]</font> <font color="#804040"><b>=</b></font> <font color="#ff00ff">TRUE</font>;<br>

  <br>
  <font color="#0000ff">// show the login page</font><br>
  drupal_goto<font color="#6a5acd">(</font>&#39;<font color="#ff00ff">user</font>&#39;<font color="#6a5acd">)</font>;<br>
  <font color="#6a5acd">}</font></font><br>
  <br>
Thanks for taking your time!<br>
Ernst<br>
  <br>
</blockquote>
<br>
</div></div></div>

</blockquote></div><br>