SUNIL16 Posted July 28, 2008 Share Posted July 28, 2008 Hi Friends, I am doing one forum. for that i created registration and now i want to check whether the session is set or not because only registered members can post topic below is code i am using for session register <?php session_start(); $sql = "SELECT * FROM `register` WHERE `username`='$username' and `password`='$password'"; $result = mysql_query($sql) or die("Could not run the query: ".mysql_error()); $count = mysql_num_rows($result); if($count == 1) { $_SESSION["myusername"] = $username; $_SESSION["mypassword"] = $password; include("sucess.php"); } else { echo "There is no one by that username."; } ?> if session is set and he is member he can post topic. Link to comment https://forums.phpfreaks.com/topic/116986-how-to-check-session-set/ Share on other sites More sharing options...
NathanLedet Posted July 28, 2008 Share Posted July 28, 2008 if (isset($_SESSION["myusername"])){ } by glimpsing at your code tho, It does appear that you're setting the session before validating that their username and password 1) exists and 2) is valid. Link to comment https://forums.phpfreaks.com/topic/116986-how-to-check-session-set/#findComment-601624 Share on other sites More sharing options...
waynew Posted July 28, 2008 Share Posted July 28, 2008 No ??? I think he's done that with mysql_num_rows function. IF == 1, means that they exist and they're correct. Link to comment https://forums.phpfreaks.com/topic/116986-how-to-check-session-set/#findComment-601635 Share on other sites More sharing options...
waynew Posted July 28, 2008 Share Posted July 28, 2008 Why are you putting their password in the session? Link to comment https://forums.phpfreaks.com/topic/116986-how-to-check-session-set/#findComment-601637 Share on other sites More sharing options...
Tandem Posted July 28, 2008 Share Posted July 28, 2008 No ??? I think he's done that with mysql_num_rows function. IF == 1, means that they exist and they're correct. All that's doing is making sure that the persons login details are correct, not if they are actually logged in. NathanLedet's solution is correct, i believe. Link to comment https://forums.phpfreaks.com/topic/116986-how-to-check-session-set/#findComment-601640 Share on other sites More sharing options...
waynew Posted July 28, 2008 Share Posted July 28, 2008 Well isn't that kind of stating the obvious? You're not going be checking to see if a session is correct on the registration process. Link to comment https://forums.phpfreaks.com/topic/116986-how-to-check-session-set/#findComment-601649 Share on other sites More sharing options...
Tandem Posted July 28, 2008 Share Posted July 28, 2008 Oops, missread what you were saying, my apologies. Link to comment https://forums.phpfreaks.com/topic/116986-how-to-check-session-set/#findComment-601658 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.