how to keep a submitted $variable alive over multiple pages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Holy crap what a long thread.

Anyway, wouldn't using cookies be so much easier?


php.net/setcookie
User avatar
Marco van Wijngaarden
Forum Commoner
Posts: 59
Joined: Mon Jul 07, 2003 6:48 am
Location: The Netherlands

Post by Marco van Wijngaarden »

i don't have anything running myself with this host, i found out too late that this host wasn't running the latest php version actually, so now i am kinda stuck with them! Anyway, it's a Windows 2000 hosting account, they have asp as their priority i guess... i want to look into setting up an Access DB, but then again... i am new to all this... so i want to get this going before i go any further...

But what's your point asking?
User avatar
Marco van Wijngaarden
Forum Commoner
Posts: 59
Joined: Mon Jul 07, 2003 6:48 am
Location: The Netherlands

Post by Marco van Wijngaarden »

Something came to my mind, i don't understand the way session works exactly, even after reading all the stuff over and over...but this is what came to me:

Now i open my page like this:

Code: Select all

<?php 
session_start(); 
header("Cache-control: private");
then, depending on the switch, the script will continue with session_register here (for example):

Code: Select all

session_register('klantgegevens'); 
        startpage(); 
        page1(); 
        break;
Now, first of all, why should i name these sessions differently in every step since i am referring to session variables all over the page as if they are global, but i've registered sessions with 8 different names in the end...
so shouldn't i refer to those different sessionnames in order to get my variable values?

But basicly, my theory is more like: i need to update (or add new variables to) the session instead of registerring a different one, right?
I assume this is the base of my current trouble??!!

I prefer to work as secure as possible, so globals (for security reasons) and cookies (for reliability) are better not to be used i guess?
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Cookies are more secure than sessions if both are in non-secure encryped environments. People may have different opinions but from personal experience I think cookies are so much better. But for your particular case, it doesn't really matter. But the simplicity of cookies should be utilized IMHO.

Especially for a simple task such as this.

btw have you thought about using just post vars to do this? Or just plain send the mail on the 2nd page instead of involving a 3rd?
Post Reply