If you haven't already done so, connect your smartphone via Bluetooth to your PC.
To do this, on iOS, open the Settings, enter the Bluetooth menu and activate the connection if it is not already activated so that your iPhone is detectable.
On Android, open Settings, go to the Connected Devices menu and tap Associate Device.
From your PC, click on the Start menu and go to Windows Settings. Enter the section dedicated to Devices, enable Bluetooth, and click on Add a Bluetooth device.
Your smartphone should be visible by Windows, click on it to initiate the connection. Check that the code displayed on your PC screen matches the one displayed on your smartphone screen and validate the connection by clicking on Connect. Do the same on the smartphone by pressing the Associate button to validate the connection.
Now that your smartphone and computer are connected via Bluetooth, you need to enable dynamic locking on your machine. To do this, go to Windows Settings.
Go to the Accounts menu, then enter the Connection Options section from the left column. Then check the option Allow Windows to automatically lock your device when you are away in the Dynamic lock section. Windows should automatically display the name of the smartphone that will be used to lock your machine when away.
Now step away from your computer while keeping your smartphone with you. When your device is out of Bluetooth range from your computer, your session will lock after about a minute. Be careful though, depending on the devices you are using, the Bluetooth range can be more or less important.