immobiliser code and possible flat battery


Two questions for my 1997 Daihatsu Sportrak

Q.1 I have heard that there is a problem with dropping the code on an immobiliser if you want to change your battery or do some work on your car? Is there a time scale?

Q2. Also my Daihatsu Sportrak's headlights remain on when I turn the ignition on. Is there an easy solution to solving this problem as I know I am going to leave them on at some stage in the winter and flatten the battery.