because of issues with the PHPSESSID support for trans_sid has been removed from core.
unfortunately, now it's not possible anymore to set the php-settings (use_trans_sid,..) so that the session works without cookies, too. this is, because drupal_goto() has to take care about the sid.
attached is a patch, which re-adds the sid in drupal_goto() like in 4.6, but only if cookies don't work. so people can login again. but this doesn't touch the php-settings, so the trans_sid keeps deactivated and as a result the sid won't be added per default.
Comments
Comment #1
moshe weitzman commentedwhen a user first visits the site, he has no session cookie. won't this disturb his urls on the resulting page? all subsequent pages will work fine as you've noted.
Comment #2
killes@www.drop.org commentedHow well is this tested? Do we need all four checks in the if clause?
Comment #3
fagoad #1
hm, unfortunatley yes - and i don't see any way to fix this..
however i don't think it's very common to have a drupal_goto() on the entry page. and if, 1 click later the phpsessid would be gone.
looks like, that this is the price to pay for allowing logins without cookies?!
ad#2
yes i think they are all necessary. the test for session_id() is necessary when logging out, because there the session is destroyed before drupal_goto() will be called.
i tested this patch with a recent cvs install and verified that logging in and doing a drupal_goto() works correctly both with and without cookies.
Comment #4
moshe weitzman commentedwhen a crawler visits your site he indexes all the links from your first page view. these can't have session ids in them
Comment #5
fagohm, yes..
but does a crawler usually allow cookies?
i thought no, so it would index all pages with the sid.. isn't that a general problem, when you use trans_sid?
Comment #6
killes@www.drop.org commentedWe don't want sids displayed if the client does not understand cookies. Maybe test fir http 10. vs 1.1?
Comment #7
fagohow else keep a session without cookies?
what woud testing for http1.0/1.1 help?
setting a correctly http status code in drupal_goto would perhaps be good, but imho that's another topic?
to make it clear,
this patch doesn't touch the default php-settings. session ids won't be displayed even if the client doesn't allow cookies.
but with this patch administrators can change the php-settings in settings.php to allow logins without cookies. yes then users (and crawlers) will see session-ids in there urls if they don't allow cookies, buts thats how php-session without cookies work and thats what the site-admin has conifgured.
without this patch, the admin can activate trans_sid, but it just won't work without cookies.
Comment #8
MentalFS commentedAren't session IDs only important for logged in users?
If so a check for anonymous user could help for better results with crawlers and first visits.
Comment #9
jt6919 commentedI get tons of PHPSESSID's when the search bot visits my site (and is indexing it), but I am using 4.7.3. Can anyone help?
Comment #10
paddywwoof commentedA few months ago I had one site working ok when cookies were switched off by changing the settings.php file
other sites I tried it on didn't, apparently because enable-trans-sid was switched off at a higher level (when compiled?). Now the site it worked on doesn't any more! I can only assume that this is because of some general security alert. If I do:
I get a '0'.
I have tried putting the suggested patch into common.inc (but taking out the check for use_trans_sid obviously) and session_id is remembered only so long as I goto pages using form buttons. As soon as I click on a normal link it looses the session. Short of hacking the page rendering in the theme to add the suggested code to all links is there a way of fixing this? I wondered about looking at the l() function.
Any help or suggestions welcome
Paddy
Comment #11
paddywwoof commentedI hacked the url() function in includes/common.inc, as drupal_goto() and l() use this, as follows and it seems to work. Obviously the links are messy with cookies switched off.
Comment #12
mlncn commentedEr, subscribing.
I know this thread is very old but think it's important that Drupal work without cookies, and at the moment it seems to... be supposed to... with difficulty? I couldn't get it to work in Drupal 5 in my testing.
Ideally, following the idea of progressive enhancement / graceful degradation:
Theoretically this shouldn't be asking the impossible, but I'm not sure PHP's session handling can do it. If not, could a Drupal module?
I apologize if I'm way off base, and the above is easy, but pointers to resources on how to set that up would be appreciated. I followed the instructions in settings.php and even set
Agaric has PHP5 on our servers and it should work with just changing settings.php, but I could not log in with cookies turned off.
This is the result from
php --info:Set
php_value session.use_trans_sid 1in <Directory /> and <Directory /var/www> in the Apache sites-available directory. Did not work either. Thanks for listening.ben, Agaric Design Collective
Comment #13
owen barton commentedWe recently needed to do a site without cookies being used at all (even if the browser supports them), so I thought I would document the changes needed here (note the word 'document' - this is not a proposed patch!) in case anyone else needs to do this. The patch in #11 is not ideal, because PHP can already rewrite regular URLs to add the session - no need to duplicate this functionality.
Drupal used to support a trans_sid, URL-based-session configuration (there was some code in 4.6 drupal_goto to insert the session id into http redirection urls), however this approach was deemed to much work to support on all the different server platforms and was never really used by anyone (there was never AFAICS a way to 'fall back' to a no-cookie setup for browsers that don't support cookies - just switch to using trans_sid sitewide) and so this code was removed in 4.7. Since 4.7 you have officially needed cookies to log in to an unpatched Drupal site and (if you look at my patch) you will see that other cookie specific code has been added since the first 4.7 release, so I think we can officially put this to 'won't fix'.
If someone comes up with an elegant way to 'fall back' to URL based sessions for browsers that don't have cookies, that works well on all the different server platforms, then I can see that being an option - but for now I think this issue is closed.
Anyway - back to my patch. Here are the settings.php lines that we are using with this:
Comment #14
owen barton commentedOne other note with my patch (#12) - this doesn't include the later improvements to session.inc to stop web crawlers and first-time visitors getting a new session, so you will want to monitor your sessions table size if you use this. That said, if you expire sessions after an hour (as we are) then you shouldn't have too much trouble.
Comment #15
smartuser commentedI applyed patch #13 on a Drupal 6 test site. It seems to work. Thank you.
Comment #16
scifisi commentedI've just tried #13 on my site (Drupal 6.14) and went to the domain name and found that my site went to the 'initialse' page as it is when I first set up a Drupal site - Yikes!
Comment #17
deepakray321 commentedHi Paddy,
i am facing the same issue.tried your code but got no luck.
Would really appreciate if you could give me some more ideas on this .
Thanks in advance.
Regards,
Deepak
Comment #18
deepakray321 commentedHi Owen,
I am facing the same issue.Tried your patch but got no luck.
Could you please send the files you have changed for this issue.or any other way around.
I am using drupal 6.
thnks in advance.
Regards,
Deepak