Jump to content
Larry Ullman's Book Forums

Ch. 5 P. 127-130


Recommended Posts

In the source code and as well as the book you write  

if (isset($_SESSION['user_id']) && !isset($_SESSION['user_not_expired'])) {
		echo '<div class="alert"><h4>Expired Account</h4>Thank you for your interest in this content. Unfortunately your account has expired. Please <a href="renew.php">renew your account</a> in order to access site content.</div>';
	} elseif (!isset($_SESSION['user_id'])) {
		echo '<div class="alert">Thank you for your interest in this content. You must be logged in as a registered user to view site content.</div>';
	}

and it displays the error that the member needs to renew, However I set the date to expire a month out on both my admin and member logins. when I take out the "!" from the second parameter it fixes the problem and the error message goes away. Was the "!" a mistake or am I not doing something correctly? I have been running off of the full scripts download and only tweaking things to sync up with my database. Also after I removed the "!" when I click on a category after it displays no error and I go to a page.php and click back to a category, or click on a different/same category I get the error to renew. Insights would be greatly appreciated. 

Link to comment
Share on other sites

New information, if I leave the "!" in on the second parameter I get the warning to renew when I click on a category, but after that if i refresh or click on a page link and then go back by clicking on a category the warning goes away. Im not sure why the warning if displaying at all. Also, when clicking around as a guest, when i click on a category I get the appropriate message, but when I click on a link to a page, somehow it logs me in as a member

Link to comment
Share on other sites

  • 1 year later...

I am also having the problem that when attempting to view pages from the sidebar (categories.php) it tells me I am expired (even after adjusting my expire date in the database to months out.  I'm wondering if $_SESSION is set to "true" or even if "false" (login.inc.php line 27) isn't it still "set" either way?  So no matter what the expired status, the error is going to display?

 

I should note that I only started having this problem after commenting out the test code for sidebar tests in index.php and page.php (downloaded files) which set the session ['user_not_expired'] to "true" (I realize this couldn't be right, either).

Link to comment
Share on other sites

  • 3 weeks later...

Larry, if you were asking me, then yes I finally got it to work.  What I had to do was change line #52 in login.inc.php from

 

if ($row['expired'] === 1) $_SESSION['user_not_expired'] = true;

 

to:

if ($row['expired'] == 1) $_SESSION['user_not_expired'] = true; (removed one "=" from the equality.)

 

It also worked if I changed the equality to "== true".  But with the triple = sign I kept getting the Expired warning when attempting to view the categories or documents whether signing in with an expired or an unexpired user.

 

Thanks for checking back!

Link to comment
Share on other sites

 Share

×
×
  • Create New...