I am using session to use variable of one page to another. I have written two program one for registering variable another for printing the value of registered variable. But when I am printing registered variable it is showing nothing. my programes are <?php session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php session_register("product1"); $product1 = "abcd"; print session_encode(); print "\nproduct registered"; ?> </body> </html> Second program is ---- <?php session_start(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php print "your chosen produts are \n\n"; print $product1; ?></body> </html> Please solve my problem.
Forget about all this session_register() crap. It only works if register_globals is enabled, and besides that, it's horribly ugly. Use sessions like this: (Page 1) <?php session_start(); $_SESSION['foo'] = 'bar'; ?> PHP: (Page 2) <?php sessio_start(); echo $_SESSION['foo']; ?> PHP: Simple as that.
Why would you store a password at all? It's as safe as the method you use to protect/handle your sessions.