shadow mapping with multitexturing (for experts I suppose)

I was quite frustrated before I made shadow mapping work. I used a demo from OpenGL Distilled book as a template, where the depth map is used as a second texture, while the first unit is regular color texture. The problem why I lost almost 2 days to make things right is that I didn’t re-set the eye planes for the second texture unit upon each repaint. And my wonder is why this is neccessary anyway. I configure both texture units in the initialization code like this:

glActiveTexture(GL_TEXTUREi);
glEnable(GL_TEXTURE_2D);
glEnable(…);
glTexParameteri(…);
glTexGeni(…);
glTexEnvi(…);

I load the first texture from file, and I calculate the second (i.e. the shadow map), by drawing the scene from light view, copying the depth buffer to texture, and then setting ;

glTexGenfv( GL_S, GL_EYE_PLANE, &(lightMatrix[0]) );

where lightMatrix is a concat of four matrices (but those who did shadow mapping must know what I am talking about).

All of the above functions change the active texture unit’s state which should remain unchanged when the texture units are switched. For some reason, however, I have to set the eye planes (as in the above line) on each repaint, even if I changed nothing else about the shadow map or second texture unit meanwhile. As if the switch to the other texture unit (which I must do because I have two textures bound to it) would reset the eye planes.

Can someone please clarify this OpenGL behavior and tell me if something else about the texture state changes in the same manner?

In the end, and this could be quite mathematical, what is the difference between using the light-view matrix to set the texture eye planes (which supposedly transform the texture coordinates into light-space) and setting the texture transformation matrix directly? Wouldn’t the latter transform in the same way? Or is it something about coordinate interpolation?

Hard to say what your actual problem is with so little code, but some clarifications:
glTexParameter is per texture object not per texture unit.
glTexEnv is per texture unit,
glTexGen is per texture unit, or better per texture coord array, but in the fixed function pipeline there is a one to one relation between coords and unit.

"In the end, and this could be quite mathematical, what is the difference between using the light-view matrix to set the texture eye planes (which supposedly transform the texture coordinates into light-space) and setting the texture transformation matrix directly? Wouldn’t the latter transform in the same way? Or is it something about coordinate interpolation? "

TexGen generates texture coordinates from vertex data, the texture matrix transforms texture coordinates and comes after TexGen. See OpenGL 2.0 Spec Chapter 2.6 Figure 2.2.
You would need to send the vertex data as texture coordinates if you want to use the texture matrix instead of the TexGen functionality.
All this is obsolete with programmable pipelines anyway, there you just do the calculations you want.