eldan88 Posted July 29, 2013 Share Posted July 29, 2013 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 Link to comment https://forums.phpfreaks.com/topic/280630-question-about-session-login/ 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. Link to comment https://forums.phpfreaks.com/topic/280630-question-about-session-login/#findComment-1442625 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() ())? Link to comment https://forums.phpfreaks.com/topic/280630-question-about-session-login/#findComment-1442628 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 } Link to comment https://forums.phpfreaks.com/topic/280630-question-about-session-login/#findComment-1442652 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. Link to comment https://forums.phpfreaks.com/topic/280630-question-about-session-login/#findComment-1443043 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 Link to comment https://forums.phpfreaks.com/topic/280630-question-about-session-login/#findComment-1443044 Share on other sites More sharing options...
eldan88 Posted August 2, 2013 Author Share Posted August 2, 2013 Never mind! I corrected the issue. Link to comment https://forums.phpfreaks.com/topic/280630-question-about-session-login/#findComment-1443074 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.