Solved

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

Posted on 2016-10-04
3
54 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 56

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

749 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