Jump to content

querystring after redirect to login page


stijn0713

Recommended Posts

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=

 

 

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.