doesn't log in until after second page load
tripper54 - July 3, 2009 - 05:58
| Project: | IP Login |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
Hi there,
I notice that after I set up an IP login, when I go to www.mysite.com I'm not logged in. It's not until after I click a link, ie, another page loads after the front page, that i'm logged in.
Has this got something to do with caching? Is there anything I can do about this?
Cheers!

#1
I believe this might be related to issues with browser cookie implementation. The first cookie is sent at the start of the page request and the system hasn't yet processed the login status. It takes another page load for the system to recognize after the login because the client didn't have the cookie on the first page load to send.
#2
Actually, it might have to do with the use of hook_init() instead of hook_boot()
http://api.drupal.org/api/function/hook_init/6
hook_init() doesn't run on cached pages, so if the first page you loaded was cached, it wouldn't even attempt to authenticate you. I'm sure it's just a missed update from 5.x to 6.x where hook_boot() was first introduced and the behavior of hook_init() changed.
#3
This patch switches to hook_boot() and conforms to Coder analysis at the minor level.
#4
Hi there,
So is this just a matter of renaming the ip_login_init() function to ip_login_boot()?
I tried that and it seems the login function check doesn't get called at all.
I don't want to apply your patch as I'm already running a modified version of the module (see http://drupal.org/node/352102 ).
#5
I think it ought to be during boot, which means you should be able to rename the function, but I'm not sure if all the functions in the init version are available that early in the bootstrap (like ip_address()). I guess that's my fault for uploading a dirty patch - I should have split the Coder part out as a separate submission.