On my 2002 Forester the keyless remote became intermittent in its operation and then stopped working completely.
I got a new battery put in the key fob and this made no difference; remote still not working.
Faced with the thought of spending mega dollars to replace the key / system I did a long search of the internet and eventually found this:
"Replace the old battery with a new battery- Outback, Legacy and Tribeca CR1620 battery, Forester and Impreza CR2025 battery- or equivalent. Negative side up. After the battery is replaced, the transmitter must be synchronized with the system’s control unit. Press either the Lock or Unlock remote button 6 times to synchronize the unit"
So, in desperation, rather than expectation of success I pointed the remote at the car, pressed the 'lock' button six times, waited a couple of seconds and then pressed the 'open' button.
It worked!
Made my day