Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by desjardins

  1. Well the issue for me was that I wasn't using HTTPS rather http - my host helped me figure it out and now it works EVEN with my sloppy code..
  2. This is a two part question... my previous post was surrounding an issue with Sessions, now I was told that it may be a server side issue so I contacted my host provider who said to me that sessions cookies REQUIRE https?? now this can't be valid because I've had no issues with sessions prior to this week - second part of this is, is there something I'm missing with maybe an updated versions? PS: yes, i'm new and simply trying to learn...
  3. and what is normal login system that every other site does?
  4. now I'm curious if it's something with my server because I did a very simple script and it too isn't carrying the session values? <?php session_start(); //set session var $_SESSION['favColor'] = "blue"; $_SESSION['favCat'] = "Stella"; ?> <a href="test2.php">GO TO TEST 2</a> <?php session_start(); //get session vars $favColor = $_SESSION['favColor']; $favCat = $_SESSION['favCat']; echo "My Favorite Color is: " . $favColor . " and my favorite cat is: " . $favCat; ?> <a href="test1.php">Go Back</a>
  5. Ok, so regarding the only have redirect in the same page location, I'm learning here so please.. I actually downloaded a reg and login script... then deleted everything and tried written from scratch.. that script was going from login.php to server.php to handle the server statements, then redirecting back to login.php or index.php... so how am I doing it directly??
  6. Also, $username is set properly because the sql statement uses $username no problem...
  7. No, login_user is checking that the login form was submitted then directly after that I'm setting $username = $_POST['username'];
  8. I know that lol - I just added that line to get my point across - if I removed the header redirect I get the echo, so that tells me the $_SESSION['username'] hold that data I want it too at that point - then when I re add the header redirect the index.php isset($_SESSION['username']) don't trigger meaning the data is gone..
  9. Hey Guys/Gals Benn awhile - so I'm confused on what's happening here. session_start() being called on every page, index.php, registration.php and server.php aswell as login.php. Now when I go too login - if I edit the code to echo the $_SESSION['username'] it works fine - gives me what I expect... I set the $_SESSION['username'] = $username and very next line header('Location: index.php'); this is where the issues is it's loosing the session data and I can't figure out why... so here are the two files if someone can point me in the right direction.. index.php <?php ob_start(); session_start(); if (!isset($_SESSION['username'])) { echo print_r($_SESSION); }else { echo print_r($_SESSION); } ?> <!DOCTYPE html> <html> <head> <title>Home</title> <link rel="stylesheet" type="text/css" href="styles/style.css"> </head> <body> <div class="header"> <h2>Home Page</h2> </div> <div class="content"> <!-- notification message --> <div class="error success" > <h3> <!-- there was error code display here --> </h3> </div> <!-- logged in user information --> </div> </body> </html> server.php <?php ob_start(); session_start(); ini_set('display_errors', '1'); ini_set('html_errors', '1'); error_reporting(E_ALL); //make connection with dba_close $username = ""; $email = ""; $errors = array(); $host = "localhost"; $db_username = ""; $db_password = ""; $db = ""; $conn = mysqli_connect($host,$db_username,$db_password,$db); if (mysqli_connect_errno()) { echo "Connection Failed... please contact support". mysqli_connect_error(); } //login user form details if (isset($_POST['login_user'])) { $username = $_POST['username']; //login for form initiated $user = "SELECT * FROM `users` WHERE `username` = '".$username."'"; $action = mysqli_query($conn,$user); while ($row = mysqli_fetch_assoc($action)) { if (mysqli_num_rows($action) === 1) { $_SESSION['username'] = $username; // echo "<br>"; // echo $_SESSION['username']; <-- this works echo's the username, if I remove header location redirect header('Location: index.php'); exit(); }else { echo "Username not found"; } } } ?>
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.