Sometimes (and I'm not really sure why), you need to do a session_write_close() before your call to your header() redirect (but after you're all done accessing $_SESSION). You might give that a try and see if it helps.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
session_start() always has to come at the very top of all other code (php or html) so move that out of your if statement to the top of your code and then try your original code again (I have also changed die() to exit()).
PHP Code:
<?php
session_start();
// Other code here that you have removed for your question
$sql = "SELECT * FROM $tbl_name WHERE username='$username' AND password='$password' LIMIT 1";
$run = mysql_query($sql);
$count = mysql_num_rows($run);
session_start() always has to come at the very top of all other code (php or html) so move that out of your if statement to the top of your code and then try your original code again (I have also changed die() to exit()).
PHP Code:
<?php
session_start();
// Other code here that you have removed for your question
$sql = "SELECT * FROM $tbl_name WHERE username='$username' AND password='$password' LIMIT 1";
$run = mysql_query($sql);
$count = mysql_num_rows($run);
now how exactly is session working? Do I need to call the page in which the check process happens on my protected page? I've been playing around with different ways and I seem to lack in luck. How does php handle this process is more so what I'm asking.
Edit: currently, on my protected page I just use require(checkpage).. and no error report.. however it's forgetting the user logged in I think because I get redirected to login page. Any tip?
Last edited by jazzmasterkc; 01-05-2013 at 04:26 PM.
Bookmarks