Get help with the freeCodeCamp programming curriculum.
SESSION WHEN PAGE LOADS
// ============================================
function checkSession() {
const session =
JSON.parse(
sessionStorage.getItem(
“session”
)
);
if (!session) {
showLogin();
return;
}
// Check token expiry
const currentTime =
Date.now();
const tokenExpired =
currentTime >
session.loginTime +
60 * 60 * 1000;
if (tokenExpired) {
sessionStorage.removeItem(
“session”
);
alert(
“Session expired. Please login again.”
);
showLogin();
return;
}
showDashboard();
}
// ============================================
// START APPLICATION
// ============================================
checkSession()
Hi , i just joined freecode camp and i need my way through can you help me
There are two ways you can format your code to make it easier to read and test:
- After you copy/paste your code into the editor, select it by dragging your cursor over it then click the (
</>) button in the toolbar to automatically wrap your code in backticks. (You can click on the animated demo image below to enlarge it.)
- Manually add three backticks on a new line above your code and on a new line after your code. Note that a backtick is NOT the same as a single quote('). To find the backtick key on your keyboard, see this post.
To see changes to your post as you make them, you can click the (M+) button on the toolbar to bring up the rich text editor:
please create your own posts with your questions @tidakabi

