I am using PHP and bootstrap and trying a project for my first time. I am a beginner in programming. Someone explain to me about SESSION and how can I use it. I want to redirect to the login page when users are not logging and enter from file dir. suggest some code for me and suggest some tips I will try to learn it. Thank you
Asked
Active
Viewed 53 times
-1
-
1Welcome to SO! When you place a question try to add a minimum content: input sample, expected output sample, what did you try, research and where are you stuck. So leave a question, show us your code, what did you try and your research: https://stackoverflow.com/help/how-to-ask – borchvm Jan 24 '20 at 07:56
-
1What I suggest you learn to do first of all, is basic research. Had you typed for example just “php redirect user if not logged in” into Google, you could have landed at https://stackoverflow.com/questions/16735747/php-redirect-if-not-logged-in in no time, and that explains the basic principle already. – 04FS Jan 24 '20 at 08:14
-
Does this answer your question? [PHP redirect if not logged in](https://stackoverflow.com/questions/16735747/php-redirect-if-not-logged-in) – LHSnow Jan 24 '20 at 08:31
-
Thank you, friend. Finally, I found the solution. – Thura Sitt Naing Jan 24 '20 at 08:37
1 Answers
0
After login generate encrypt string and expire time. Save in storage on server and send in storage client (example cookie).
Every request match it beetween client and server. If expired, send 302 redirect to login page. If encrypt string client do not send - redirect 302 to login page.
Evgenii Kuznetsov
- 29
- 6