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!
session_start();
/* USERNAME */
$_SESSION['registration_details']['username'] = $get_username; //the actual username typed
$_SESSION['registration_details']['username_check'] = $username_check; //does username exist in database already?
$_SESSION['registration_details']['get_username_check'] = $get_username_check; //did they type anything at all?
$_SESSION['registration_details']['username_validity_check'] = $username_validity_check; //is it a valid username?
/* EMAIL */
$_SESSION['registration_details']['email'] = $get_email; //the actual email address typed
$_SESSION['registration_details']['get_email_check'] = $get_email_check; //Did they type anything?
$_SESSION['registration_details']['email_check'] = $email_check; //Does it exist in the database?
$_SESSION['registration_details']['email_validity_check'] = $email_validity_check; //Is it a valid email address?
This is taken from an example site I'm working on. Assume that $get_username and all the other vars are already loaded and declared etc.
<?php session_start();
$prodid ='$_GET[prodid]'
$price ='$_GET[price]''
$_SESSION['prodid']=$prodid; //What I'm thinking is, this will overwrite the first product added - How wold I get around this?
$_SESSION['price']=$price;
?>
Firstly, you cannot parse variables inside second quotes.
Secondly, to add multiple items to a variable you have to define it as an array.
I would organize it somewhat like
Jcart wrote:$_SESSION itself is an array, and can be treated just as other variables
Nice, I think that will really help the original poster of this thread, and for me, demystifies sessions that little bit more. All I have to figure out now is how to delete / remove a session.