Getting session ID in Drupal 6
Drupal saves its sessions in the sessions table. One can always query they table to get the session ID. There is however a faster way.
If the user is logged it, the session id can be found with the following code:
global $user; $user->sid;
In any case the session id can also be read from the cookie:
$_COOKIE[session_name()];
Theming a form in Drupal 6
Form theming in drupal 6 is quite flexible. One of the nicest tricks is the ability to theme the form in stages. Calling drupal_render on a part of the form will not only return the rendered version of it, but it will also mark that part as rendered so that when you call the final drupal_render over the whole form, it will not re-render the parts already rendered.
Remember that in order for the form to function correctly there are some hidden fields in every form that must be added to the form. Also drupal needs to generate the form tag. Therefore it is my advise, after doing the custom rendering of the parts you want, add a general render of the form. this will reduce the chance of problems with form submission.
Special thanks to Rolf van de Krol, for this tip.
How to truly disable drupal cache
Drupal, like most CMSes uses cache intensively to speed things up. In a production site that is exactly what you what. However when developing, cache can cause you much pain.
If your an expert in drupal you probably already realized when you need to clear the cache in order to see changes and when not too. the developer module even makes it quite easy to do. However for me, and I am quite sure to quite a lot of other people it is not that clear.
"Wait", you might say. "Drupal has a disable cache setting". You would be right to say that. Only it doesn't completely disable the cache, only part of the cache, namely the page caching. To truly disable cache you need to do a bit of a hacking to the cache code. Yes I know they say to never hack core (cache is part of the core drupal release). for me this was worth it. I figure as long as you remember its there and don't use it in production you should be fine. The following piece of code needs to be added in include/cache.inc. There are two functions there that you need to edit:
cache_getcache_set
In cache_get place the code right after the global $user. In cache_set place it at the start of the function. Here is the code that you need to add.
if(variable_get('cache', CACHE_DISABLED) == CACHE_DISABLED) {
return 0;
}
Kudos for this hack goes to Rolf van der Krol. Cheers mate.