Use $_SESSION
-!
session_start();
$_SESSION['username'] = $_POST['username'];
You of course want to filter/sanitize/validate your $_POST data, but that is outside of the scope of this question...
As long as you call session_start();
before you use $_SESSION
- the values in the $_SESSION
array will persist across pages until the user closes the browser.
If you want to end the session before that, like in a logout button --- use session_destroy()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…