I have found a few things that you can try when your Nokia 5310 is stuck on the security code.
- When the phone requests a code try the last 4 digits of your phone number
- If that doesn't work, try 12345
- If that doesn't work enter a few random codes and your phone will request a PUK or PIN code, you can get these from your network carrier.
The url is http://www.nokialockcode.com/calculate.php but please be careful.