how to read HTTP query string?

Permalink
I can send a parameter to a concrete5 webpage, but how do I read it?

For example, the parameter "token" is attached in an http query string:

https://www.mydomain.com/myspecialwebpage.html?token=4949...

(This is just an example, but any other method to send a parameter to a concrete5 webpage where the parameter is embedded in the URL would be acceptable.)

Could someone give a very simple example showing how to read this parameter and compare it with a value and if it agrees allow the user to access the webpage, and if not display a message instead?

Where would the code reside in concrete5? How to set this up?

Also, is there anyway to hide this code so the user can't view it? (Obviously, if they can see the comparison check then they know how to fake the URL to gain access).

View Replies: View Best Answer
INTcommunications replied on at Permalink Best Answer Reply
INTcommunications
mysite.com/

I am just guessing here but I think it's a get i.e.

In the view function of the controller

$sort_by = $_GET['sort'];

if ($sort_by == "name") {
$pl->sortByName();
} else {
$pl->sortBy('teaching_date', 'desc'); // Order by a page attribute
}

I am an experienced coder ( Coldfusion ) but this is just a guess with concrete
exchangecore replied on at Permalink Reply
exchangecore
As mentioned by INTcommunications you can get the query parameter out using $_GET['token'] in the controller of the page.

It would generally be considered bad practice to use "Security by Obscurity" and relying on hiding that ID for page security. Instead, you should look into how to secure that page using Concrete5's permission system.
jwapp replied on at Permalink Reply
> using $_GET['token'] in the controller of the page.

Is this documented somewhere? I have no idea what it means or how to implement.
exchangecore replied on at Permalink Reply
exchangecore
I am assuming that this is some sort of custom built single page. You should take a look at the developers documentation for more information on this. More specifically:http://www.concrete5.org/documentation/developers/pages/mvc-approac...