Solved

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

Posted on 2016-10-04
3
42 Views
Last Modified: 2016-10-05
I had this question after viewing Reverse asset logic not working.
0
Comment
Question by:Black Sulfur
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 52

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 108

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
The viewer will learn how to count occurrences of each item in an array.
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…

930 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now