-2
$session = &$_SESSION;

I acces $_SESSION by this var: $session;

How can I remove $_SESSION var without deleting its content ?
I want to can acces session data only from $session var.

Can you please give me any solution?

Note: I don't need to know if it's helpful or not.

Edit:

I get session's address (&$_SESSION) because I want also to make live modifications in $_SESSION (but using $session var).

I want my $session modifications to exists (in $_SESSION) after refresh page, but I don't want to can access directly $_SESSION.

  • What are your concerns with needing to remove the superglobal `$_SESSION`? Deleting a variable while keeping the contents doesn't make technical sense. Just `$session = $_SESSION; unset($_SESSION);` good luck setting session variables. – castis Mar 01 '19 at 16:50
  • I think `$session = $_SESSION;` is what you want. Then you can destroy the session. This seems strange though. – user3783243 Mar 01 '19 at 16:53
  • No seriously... why? – Xatenev Mar 01 '19 at 16:55
  • @castis, "I don't need to know if it's helpful or not.". I don't want to lose $_SESSION data. I want to can modify it from $session. – Valentin Tanasescu Mar 01 '19 at 16:55
  • You `want also to make live modifications in $_SESSION` or `remove $_SESSION`? This is unclear. You can't modify something that is destroyed/unset/removed. Your `$session` is a reference to `$_SESSION`. – user3783243 Mar 01 '19 at 16:55
  • I want to make live modifications in $_SESSION from $session reference. And I also want TO NOT CAN acces session directly from $_SESSION ("but using $session var"). – Valentin Tanasescu Mar 01 '19 at 16:57
  • @ValentinTanasescu im not particularly concerned with what you need, thanks – castis Mar 01 '19 at 17:01

1 Answers1

0

Use this to perform what you are intending to... Hope you'll get this $session = htmlentities(var_export($_SESSION, true));

Aayush Sahu
  • 126
  • 1
  • 1
  • 10