Sensor on transmission
Check if the stop light comes ON when you press the brake pedal, if it doesn't, then the problem is the stop light switch, which is the same switch used to release the shifter.
Brake light works
Press the brake and listen for the shift lock... likely a problem with the shift lock solenoid. This is a device in the shifter that makes that clicking sound when you step on the brake. It can short out or just simply stick. Was anything spilled on the shift?
Looking for a Used Altima in your area?
CarGurus has 83,130 nationwide Altima listings starting at $670.
Search Nissan Altima Questions
Are you a UK consumer? CarGurus now has a discussion forum in the UK.
Nissan Altima Experts