Jump to content

narpassword000

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

narpassword000's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. After a LONG delay, I've got the chance to try to work on this again finally. The cookie seems to be set immediately upon login, according to Chrome's cookie reading tool, but will not appear in-browser until the page is fully refreshed. Clicking a link that returns you to the same page does not work, nor does going to another page. I'm almost certain that this is because the header.inc is just being accessed through a local copy that doesn't get re-run until a basic refresh, or something like that, but I don't have the expertise (or beginner-ise, for that matter) to know if I'm right, or more importantly how to fix it.
  2. I've tested it a bit further. The cookie will not be read even if I change pages until I refresh the page, no matter which page I'm on. I had a thought. The code to read the cookie is stored in a separate file (header.inc) that is used for the banner, navigation bar and what-not in every page. I think this might be causing the issue...is there any way I can resolve this without having incorporate this file into every page? Is there a way to force the browser to reload the header when I change pages? It's just a basic <?php include "header.inc"; ?> at the top of the main div block.
  3. I've spent some time on google hunting for a solution to my issue, but to no avail. I'm doing a PHP-based website for a school project, and have encountered a weird user experience glitch. When the user attempts to log into their account, they are sent to a new page where the login info is verified and if it correct, a cookie is set. Currently for testing purposes the cookie is just their name. A variable is then set to determine what to do later. <?php $loginfail = true; $fileContents = file_get_contents("users.txt"); $ids = json_decode($fileContents, true); foreach ($ids as $user) { if ($user['email'] == $_POST['email'] && $user['pass'] == $_POST['pwd']) { $loginfail = false; if (isset($_POST['remember'])) { $expire = time() + 60 * 60 * 24 * 30; setcookie("user", $user['first'], $expire); } else setcookie("user", $user['first']); break; } } ?> This is really basic user verification for testing purposes. Further down in the page, if the login variable was set to false then I used Javascript to redirect back to the homepage. <script language="javascript"><!-- var t = setTimeout("redir()", 2000); function redir() { location.replace("index.php"); }//--> </script> However, when I reach the homepage, the cookie isn't being read until after I refresh. I assumed that when I sent the user to a new page it should be considered a fresh load and the cookie would be accessible. Apparently I was wrong. Any advice?
×
×
  • 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.