Jump to content

[SOLVED] Persistent variables without the use of sessions or cookies


NathanBrisk

Recommended Posts

For my client I need to have a variable transparently passed from one php page to another.

 

I don't want to use sessions/cookies because I don't want someone to be able to open a new tab and have the session variable persist into the other tab. This variable can be set in PHP and I'd like for it to be passed via POST (if this is possible).

 

Is this possible?

For my client I need to have a variable transparently passed from one php page to another.

 

I don't want to use sessions/cookies because I don't want someone to be able to open a new tab and have the session variable persist into the other tab. This variable can be set in PHP and I'd like for it to be passed via POST (if this is possible).

 

Is this possible?

 

It's possible by using hidden form inputs:

 

Page 1 -

<form action="page2.php" method="post">
   <input type="hidden" name="hidden" value="something" />
</form>

 

Page 2 -

<?php
   $hidden = $_POST['hidden'];
   .
   .
   .
?>

<form action="page3.php" method="post">
   <input type="hidden" name="hidden2" value="<?php echo $hidden; ?>" />
</form>

 

Page 3 -

<?php
   $hidden2 = $_POST['hidden2'];
   .
   .
   .
?>

 

And so on.  Keep in mind, this isn't a secure way to transfer data.  Hidden inputs aren't displayed on the screen, but still show up in the source code of the document.  So, don't use it for anything sensitive.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.