User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 401,961 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,892 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting

Can't create sessions

Join Date: Oct 2007
Location: Penang Island, Malaysia
Posts: 170
Reputation: lordx78 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
lordx78's Avatar
lordx78 lordx78 is offline Offline
Junior Poster

Re: Can't create sessions

  #15  
Feb 26th, 2008
  1. $LoginRS_query = "SELECT user_id, first_name FROM adminprofile WHERE username='$loginUsername' AND password='$loginPassword'";
  2. $LoginRS = mysql_query($LoginRS_query) or die(mysql_error());
  3. $loginFoundUser = mysql_num_rows($LoginRS);
  4. $record_row = mysql_fetch_array($LoginRS);
  5.  
  6. if ($loginFoundUser) {
  7.  
  8. session_name ('YourVisitID');
  9. session_start();
  10. $_SESSION['user_id'] = $record_row[0];
  11. $_SESSION['first_name'] = $record_row[1];

Just wanted to confirm with. Is this the way you want me to do?
or

  1. $LoginRS_query = "SELECT user_id, first_name FROM adminprofile WHERE username='$loginUsername' AND password='$loginPassword'";
  2. $LoginRS = mysql_query($LoginRS_query) or die(mysql_error());
  3. $loginFoundUser = mysql_num_rows($LoginRS);
  4. $record_row = mysql_fetch_array($LoginRS);
  5.  
  6. if ($record_row>0) {
  7.  
  8. session_name ('YourVisitID');
  9. session_start();
  10. $_SESSION['user_id'] = $record_row[0];
  11. $_SESSION['first_name'] = $record_row[1];


And another thing is, if I remove the 'AGENT' from this page and I have also remove it from validated.php
  1. <?php
  2.  
  3. session_name ('YourVisitID');
  4. session_start(); // Start the session.
  5. //print_r($_SESSION);
  6. $MM_redirectLoginFailed = "admin.php";
  7. $MM_redirecttoReferrer = true;
  8.  
  9. // If no session value is present, redirect the user.
  10. if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT'])) ) {
  11.  
  12. echo "<script type='text/javascript'>location.href='$MM_redirectLoginSuccess';</script>";
  13. exit(); // Quit the script.
  14. }
  15.  
  16. ?>

So what kind of session validation should I place here. Please advise.
"I might not be the BEST but I'm not like the REST!"
Reply With Quote  
All times are GMT -4. The time now is 6:16 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC