Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.