eldan88 Posted July 29, 2013 Share Posted July 29, 2013 (edited) Hey, I am trying to create a function that will only let users with an access level of 1 or 0 to be able to view a certain page. I have created a function, but I can't seem to get it work. Below is my code. Any help would be really appreciated! function confirmed_logged_in() { return isset($_SESSION['user_id']) && ($_SESSION['access'] == 1) || ($_SESSION['access'] == 0); } function store_logged_in() { if(!confirmed_logged_in() ()) { goto_page("www.urlgoeshere.com"); } } I then put the store_logged_in() function on the pages that I want users with a level access of 1 or 0 to view the page Edited July 29, 2013 by eldan88 Quote Link to comment Share on other sites More sharing options...
requinix Posted July 29, 2013 Share Posted July 29, 2013 Can't get it to work because... you get a white screen of death? if(!confirmed_logged_in() ()) {Or because of a different reason? We're not psychic: you have to tell us these things. Quote Link to comment Share on other sites More sharing options...
Joshua F Posted July 30, 2013 Share Posted July 30, 2013 Why do you have two () here(confirmed_logged_in() ())? Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted July 30, 2013 Share Posted July 30, 2013 <?php function confirmed_logged_in( ) { $returned = isset($_SESSION['user_id']) && $_SESSION['access'] == 1 ? true : false; return $returned; } function store_logged_in( ) { if(!confirmed_logged_in( )){ goto_page('urlgoeshere.com'); } //other code here } Quote Link to comment Share on other sites More sharing options...
eldan88 Posted August 1, 2013 Author Share Posted August 1, 2013 Why do you have two () here(confirmed_logged_in() ())? Sorry. That was a type on the forum, not on the actual code. Quote Link to comment Share on other sites More sharing options...
eldan88 Posted August 1, 2013 Author Share Posted August 1, 2013 <?php function confirmed_logged_in( ) { $returned = isset($_SESSION['user_id']) && $_SESSION['access'] == 1 ? true : false; return $returned; } function store_logged_in( ) { if(!confirmed_logged_in( )){ goto_page('urlgoeshere.com'); } //other code here } Hey. I actually need to it to validate the session for user access lvl 0 and 1 not just 1 Quote Link to comment Share on other sites More sharing options...
Solution eldan88 Posted August 2, 2013 Author Solution Share Posted August 2, 2013 Never mind! I corrected the issue. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.