How to put a specific variable in Session

Asked

Viewed 46 times

0

Guys, first hello everyone!! I have a question,

I need to put a variable with the URL of the specific page in Session, to be used in several later pages. The code I’m using to get the URL is this

$URL_PAG = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

But I couldn’t get it into Session without it changing on the back page. Could someone shed some light on how I should proceed?

  • How do you change it? It takes the url from the other page?

  • http://php.net/manual/en/sessionhandler.write.php

  • Look at my answer, here it worked

  • In short, I upload an image and I want to use its URL in Sesssion, I wasn’t able to use the URL in Sesssion, but dear Woton Sampaio helped a lot.

1 answer

-1

Try to make a constant:

session_start();

define("nome", "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");

$_SESSION['url'] = nome;
  • Perfect, gave straight, thank you very much!

  • @Jonatasantos nothing, if you want to accept my answer I also thank :3 kkkkk

Browser other questions tagged

You are not signed in. Login or sign up in order to post.