M
M
mranomalyy2017-04-05 08:03:21
PHP
mranomalyy, 2017-04-05 08:03:21

How to save parameter for php?

Good afternoon. I'm just starting to learn php, but already now I'm faced with the following task:
Let's say there is an example.com page. In my project, it has design A. But if you add ?lite (example.com/?lite) to the address bar, the design changes to B.
One thing that worries me is that all links that are opened in design B lead to design A, because the lite parameter is missing at the end of the line.
Is it possible to put some kind of crutch, preferably using cookies? To remember this choice.
Sorry if the question is stupid or poorly worded.
I'm looking forward to the answers. Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2017-04-05
@sanok_ps

Since the lite parameter does not matter in this case, but simply either it exists or it does not, then

if(isset($_GET['lite'])){
setcookie('lite ','true',time()+172800,"/");
$lite = true;
}

(You can find and parse setcookie parameters in the reference for the function)
And then, based on checking the value of $lite, design B can be applied. But in this case, only choice B will be remembered, as was said. That is, if example.com/ is loaded after example.com/?lite, design B will still be shown.

V
Vasya Petrov, 2017-04-05
@VasyaPertrov

Sorry if the question is stupid or poorly worded.

If we are talking about VP (judging by the label), then this is a complete ... server fur animal.
Tell us with a separate question what you want to do, why (forget about the parameters in the URL, tell about the task) and then the right solution will be found.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question