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 89,075 nationwide Altima listings starting at $1,500.
Search Nissan Altima Questions
Nissan Altima Experts
Related Models For Sale
Used Cars For Sale