Solved

When to use $_SERVER["REQUEST_URI"] and why?

Posted on 2016-10-04
3
58 Views
Last Modified: 2016-10-05
I had this question after viewing Reverse asset logic not working.
0
Comment
Question by:Black Sulfur
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
ID: 41829363
$_SERVER["REQUEST_URI"] is the current page you are on.  In your previous question you had...
$_SESSION["entry_uri"] = $_SERVER["REQUEST_URI"];

Open in new window

which saves the current page in a Session variable.  You could read that value on other pages to see where you started in the current session.  This is useful when you have more than one page that people 'land on'.  I have been using cookies to remember landing pages but that is partly because a number of the pages are just HTML and not PHP.
1
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 41829415
The question is far too broad for a simple answer.

The server variable in question stores the full request URI for the current page - the uses for this information are varied including but not limited to

- Page Tracking
- Redirection (example after sign on)
- Routing
0
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 400 total points
ID: 41830052
In the context of this article, the "entry URI" is the web address of the page that was used to enter the web site, whether or not the client is presently logged in.  Here's why this matters.  

Let's say you have visited the site, logged in, and found an access controlled page that you want to share with a colleague, or that you want to bookmark.  The link to that page does not contain your login information; the page remains password protected.  So if you send me the link, when I visit the page, the access control routines will see that I do not have the session indicator that I'm logged in.  The access control routines will store the entry URI and send my browser to the login page.  After the login is successful, the site will redirect the browser back to the entry URI page.  

Without this scheme, the client browser does not know where to go after the login is complete.  Some sites might send you to the home or "welcome" page, but if that's what you want, why not just bookmark the home page?  The point of the design is to preserve the access control environment and at the same time give the client as much control as possible, resulting in a sensible design for both the client and server.

If you've checked the "remember me" box, there is a separate cookie that tells the site that you have already been authenticated, and no separate login is needed until the cookie expires.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question