stijn0713 Posted August 2, 2012 Share Posted August 2, 2012 hello, suppose i click on a 'group 1' which will direct me to group.php?ID= 'id of the group' and in group.php i have restricted the page to logged users. Suppose they are not logged, so they are directed to logon page, after which they are redirected back to group.php. Do i lose the information of the querystring then, i.e. ?ID= Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 2, 2012 Share Posted August 2, 2012 You would have to either store it in the session, or add it to the redirect back to the login page. Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted August 2, 2012 Share Posted August 2, 2012 if a user reaches a page they do not have access to until they log in, set the query string to their $_SESSION['previous'] and redirect them to log in. Once successfully logged in, redirect them to the value in the session. Ninja'd! :shakes fist: Quote Link to comment Share on other sites More sharing options...
stijn0713 Posted August 2, 2012 Author Share Posted August 2, 2012 or add it to the redirect back to the login page that i don't understand, but adding to the session seems logic Quote Link to comment Share on other sites More sharing options...
stijn0713 Posted August 2, 2012 Author Share Posted August 2, 2012 mm, but if i add it to session, than i have to make sure that if they, after they select another group, they get the right group to see. so i guess i'll do it like this: if(isset($_GET['ID'])){ $ID_Onderzoek = $_GET['ID']; } else if(isset($_SESSION['get_ID'])) { $ID_Onderzoek = $_SESSION['get_ID']; } else { $ID_Onderzoek = "geen onderzoeksID gevonden"; } Is this how you mean it? Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted August 2, 2012 Share Posted August 2, 2012 or add it to the redirect back to the login page that i don't understand use the session, it'll serve you best. plus, you can maintain the 'previous' entry to follow the user around (useful for analytics). based on your new post: consider path to file: /home/wwwdata/pages/groups.php user goes to: site.com/groups?id=3 they aren't logged in, so redirect <?php if( !logged_in() ) { $_SESSION['previous'] = 'groups.php?' . $_GET; header('Location', 'login.php'); } then they log in: header('Location', $_SESSION['previous']; Not tested, not escaped, not sanitized. learning purposes only Quote Link to comment Share on other sites More sharing options...
stijn0713 Posted August 2, 2012 Author Share Posted August 2, 2012 Yep, i thought to do it like you, i came up with more or less the same: $_SESSION['PrevUrl'] = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; Thanks for the help 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.