Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Trouble with Login Redirect [$_SESSION['PrevUrl']

New Here ,
May 15, 2009 May 15, 2009

I'm using the DW functionality to confirm that a user is logged in before allowing access to a page. Everything works except successfully redirecting to the previous URL. Here's the situation:

  1. User accesses a page with a url such as "addtocookbook.php?recipeid=6".
  2. Since the user is not logged in, they are redirected to"login.php".
  3. After successfully logging in, the user is redirected to "addtocookbook.php" without the "recipe=6".

My login page does attempt to direct the user to the previous url (if it exists). I'm not sure if there is a simple way to make the variable $_SESSION['PrevUrl'], used by DW to redirect,  store the entire url.

Any help is appreciated.

Elie Chocron

TOPICS
Server side applications
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 15, 2009 May 15, 2009

The problem lies with some obsolete code in the Restrict access to page server behavior. Fortunately, the fix is quite simple.

The affected section of code is as follows:

if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
  $MM_referrer .= "?"
...
Translate
LEGEND ,
May 15, 2009 May 15, 2009

The problem lies with some obsolete code in the Restrict access to page server behavior. Fortunately, the fix is quite simple.

The affected section of code is as follows:

if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo);
  exit;
}

All that is necessary is to replace the three instances of $QUERY_STRING like this:

if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo);
  exit;
}

The redirect will then work correctly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 17, 2009 May 17, 2009
LATEST

Thanks! That did the trick.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines