Problem/Motivation
Visiting any page results in a new session by default making it difficult to work with web accelerators like Varnish etc.
edit: I think it might also be the cause of the PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ... UPDATE {sessions} ... error when $conf[https] = TRUE; is set.
Proposed resolution
Start the temporary session only when the user is IP restricted, and not before.
And leave the drupal_session_start() triggering behaviour to Drupal.
Alternatively, couldn't we just set drupal_page_is_cacheable(TRUE); and be done, removing the need for the temporary session?
Remaining tasks
Create patch for new behaviour.
Comments
Comment #2
codebymikey commentedAttached a patch for an implementation without using sessions.
Comment #3
codebymikey commentedComment #4
codebymikey commentedAdded logic for lazy starting the PHP session as needed.
Drupal will handle the creation if there's an active session to pass back.
I'd recommend the non-session version in #2 as it's easier to work with.
Comment #5
codebymikey commentedComment #7
smustgrave commentedSince a bug I'll include in the dev branch of D7, but D7 EOL soon. Last D7 issue here!