Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 870365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:27:43+00:00 2026-05-15T10:27:43+00:00

i have somthing like this: (if this page needs the user to be logged)

  • 0

i have somthing like this: (if this page needs the user to be logged)

if(!isset($_SESSION['usr_id'])){          //if not a logged user
    $_SESSION['redir']=curPageURL();//Saving the current page for the redirection
    header('Location: ../Session/loginFrm.php'); 
}

and in loginFrm.php, we do:

{...after validation}    
if(isset($_SESSION['redir'])){
        header('Location: '.$_SESSION['redir']);
    }else{...}

in this page, they say we should use something like this instead:

 ...
    require_once '../Session/loginFrm.php';
    exit();

This doesn’t work for me, the session variable now contains the included page, and not the current page.

What do you think about?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:27:44+00:00Added an answer on May 15, 2026 at 10:27 am

    He omits an important piece of information: resetting the execution context.

    When you do a redirect, the new page loads and can assume it is the page requested. Most pages are written like that and most PHP programmers write pages like that. It also means you can control the context better through the redirect.

    If you want to support that include() trick, then the page being included has to be written quite differently. It has to understand that it is now inheriting an execution context that may include rubbish from the calling file. It also means that the URL the user sees in their browser is not going to be the same every time. The included page/file must account for that when setting up POST targets (for instance) or you will get very bizarre errors.

    The reasoning behind his recommendation is good, but you have to look at in a wider context: principally, how often will you need to issue the redirect (but also how slow is the upstream connection)? Since it looks like a login auto-redirect, my guess would be not all that often. People are used to redirects all the time, so yours is unlikely to stand out as excessive. So put this problem off until the redirect becomes a problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to determine whether or not the user is logged in or
I have a page which needs to redirect a user to another separate system
How do we build a profile page that outputs the user's data? and this
This is a common need I have on every page: if (session[LoggedIn] == null
I have a website where I need a javascript version of the current user
I have asp.net web site in which user can login and also do logout
On a php page with javascript (jquery) in the urel I would like to
I'm developing in PHP and MySQL. The information about the currently logged in user
Ok, so this seems bad (and it probably is, but i have enough doubts
I have a photo gallery page that shows a series of thumbnails that are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.