Forum Moderators: coopster
I did not want to use viewers’ cookies – they are often disabled, I’m told.
It works. But I am brand new to sessions, and wondering if I have done this correctly.
Page1.htm contains a normal radio button form, which posts ”size”.
Page2.php has the following at the very top (pre Doctype):
<?php
session_name('thisn');
session_name('whattype');
session_start();
header("Cache-control: private"); // IE 6 Fix.
?>
In the body:
$_SESSION['whattype'] = $_POST['whattype'];
The form from Page2.php posts a value “whatsize”.
Page3.php starts:
<?php
session_name('whattype');
session_name('whatsize');
session_start();
header("Cache-control: private");
?>
In the body
$_SESSION['whatsize'] = $_POST['whatsize'];
Page4.php again starts:
<?php
session_name('whattype');
session_name('whatsize');
session_start();
header("Cache-control: private");
?>
The data is processed in the body, with the conclusion:
session_destroy();
Which, I hope, wipes all session information.
Am I handling the sessions correctly?
That said, i think kiwibrit is confusing "session" with "session variable". with one client at a time, you usually and more then 90% of the time establish only one session at a time, however one session can have any number of session variables as and when needed. So basically as Jatar_k has said, you could register all variables with one session without even needing to name session or this n that.
And just for information, even if you are seemingly assigning different names to the session, the basic session remains the same, try
session_id()
it will return same throughout your current code, that means those arent different sessions, thats one session.
so thats essantially one session with multiple session variables.
<?
session_start();
$_SESSION['var1']="anyvalue";
$_SESSION['var2']="anyvalue";
$_SESSION['var3']="anyvalue";
$_SESSION['var4']="anyvalue";
$_SESSION['var5']="anyvalue";
// and so on
?>
as far as your code is concerned, that looks perfectly fine to me, just that if i would write it, i wouldnt use
session_name('whattype');
session_name('whatsize');
no need for em.
you can simply use
$_SESSION['whattype']="anything" //as you have done.
I am sorry if this doesnt help.
Regards
Kami