2tonejoe Posted August 23, 2007 Share Posted August 23, 2007 ok. i have the mysql db setup with usernames, ids, passwords, access levels, etc .. . . I also have <?phpsession_start();?> in my template header. . . what I am not understanding is how to store the $_SESSION['*****'] variables. I have seen come code, but it isn't clear. . . what is the easiest way to use the $_SESSION for my custom variables: something like $_SESSION['username'] = 'John Henry'; $_SESSION['userlevel'] = 'orange'; I understand I can send them from my login form using $_POST, but how do I set them?? Quote Link to comment https://forums.phpfreaks.com/topic/66362-user-management-sessions/ Share on other sites More sharing options...
micah1701 Posted August 23, 2007 Share Posted August 23, 2007 <?php session_start(); $_SESSION['username'] = $_POST['username']; //or $_SESSION['username'] = "John Henery"; //or $name = "John Henery"; $_SESSION['username'] = $name; echo $_SESSION['username']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/66362-user-management-sessions/#findComment-332028 Share on other sites More sharing options...
xyn Posted August 23, 2007 Share Posted August 23, 2007 to set them... $_SESSION['the_name_here'] = $its_value_here; a Set session; this code would look like: $_SESSION['the_name_here']; to destroy them either all sessions session_destroy(); of you can kill them individually / by group using unset($_SESSION['name'], $_SESSION['name2']); Quote Link to comment https://forums.phpfreaks.com/topic/66362-user-management-sessions/#findComment-332029 Share on other sites More sharing options...
2tonejoe Posted August 23, 2007 Author Share Posted August 23, 2007 these don't have to registered as globals?? is that an old php version? Quote Link to comment https://forums.phpfreaks.com/topic/66362-user-management-sessions/#findComment-332034 Share on other sites More sharing options...
trq Posted August 23, 2007 Share Posted August 23, 2007 these don't have to registered as globals? Can you rephrase that? Quote Link to comment https://forums.phpfreaks.com/topic/66362-user-management-sessions/#findComment-332037 Share on other sites More sharing options...
2tonejoe Posted August 23, 2007 Author Share Posted August 23, 2007 $name = "John Henery"; global $name; $_SESSION['username'] = $name; do I have to global it in order for it to be available to other php pages? Quote Link to comment https://forums.phpfreaks.com/topic/66362-user-management-sessions/#findComment-332040 Share on other sites More sharing options...
trq Posted August 23, 2007 Share Posted August 23, 2007 No. The $_SESSION array is global. Quote Link to comment https://forums.phpfreaks.com/topic/66362-user-management-sessions/#findComment-332059 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.