If you've recently bought an iPhone and want to make sure all your private information - contacts, emails, photos, and other personal items - remain secure, then one of the easiest ways to do so is by adding a passcode to your device. This is a simple numeric (or alphanumeric) code that prevents anyone else from being able to access your handset.

Setting one up is very easy, and if you follow the steps outlined below then you'll quickly have your iPhone off-limits to any nosey parkers. If the worst happens and it gets stolen, then the thieves won't be able to read any of your messages, access your social media accounts, or find out your credit card and bank details.

Setting up a passcode on iPhone

On your iPhone tap the Settings app, which is the one that has a grey icon with gears inside it. From the menu that appears, scroll down until you find Touch ID & Passcode. If you've got a newer iPhone that doesn't have a physical Home button (such as the iPhone X, XR, XS or XS Max) then you'll want Face ID & Passcode instead.

How to set a passcode on iPhone: Settings

Next, scroll until you find the option to Turn Passcode On, then tap it. You'll now be presented with a page showing six circles in the middle and the number pad open beneath.

The circles each represent a number you need to enter to create your passcode. Apple defaults to six as it's a good mixture of digits (making it harder to crack) but short enough for mere humans to actually remember.

Should you wish to enter a mixture of letters and numbers instead, a longer number, or a shorter 4-digit one, than tap Passcode Options and select your preferred format from the menu that pops up. You can always change these settings later, so don't be afraid to explore each one.

How to set a passcode on iPhone: Passcode Options

When you're happy with the type of passcode you want to use, simply type it in, and repeat it afterwards for verification purposes.

You may see a message informing you that you can use the passcode to change your Apple ID password from your iPhone, and then prompting you to enter the account password itself. This is perfectly normal, so enter the required details and tap Continue.

You'll now be taken back to the Touch ID & Passcode or Face ID & Passcode menu, where you'll see that the Turn Passcode On option has now changed to Turn Passcode Off.

Beneath this there are also the options to Change Passcode, should you want to replace the one you've created, and Require Passcode. Tap the latter and you'll be given choices for how soon after you lock the display (turn the screen off) you'll need to enter the passcode again to unlock it. The default is Immediately, but if you find you're accidentally tapping the power button and locking the screen, then you might want to choose another timescale.

If you want to use Apple Pay or Touch ID then you'll only be able to have the setting at Immediately, which Apple states is 'for your own security'.

How to set a passcode on iPhone: Require passcode

You'll see another list of choices under the title Allow Access When Locked. These are various functions that you can still use without unlocking the phone, such as Siri or accessing the Notifications centre. Each one has its own switch, so you can tailor the activities to your personal taste.

Finally, at the bottom of the menu is a switch to enable the Erase Data feature. As the name suggest, this is quite a serious command, aimed at securing your phone from a thief or hacker trying to gain access by guessing the passcode.

With this turned on, it means that after 10 failed attempts at the passcode the iPhone will wipe all your data from the handset. In principle, this is a useful security feature - but if you have children who happily type numbers into your phone without realising they might be about to erase all of your accounts, or can be a bit forgetful yourself, then it might be worth disabling this for now.

That's it. You should now have your passcode in place, meaning the data on your device is far more secure than before. If you have a bad day and leave your handset on the train by accident, at least you shouldn't have any strange messages heading from it to your friends or bank.

Just to be safe, though, we'd also recommend reading our How to find a lost or stolen iPhone guide, to help you recover it again.