Newbie - Session support does not work for me

General discussion on Zend Core for IBM System i
Post Reply
lundbergrd
Posts: 2
Joined: Fri Apr 09, 2010 4:44 pm

Newbie - Session support does not work for me

Post by lundbergrd » Fri Apr 09, 2010 5:40 pm

Not only am I newbie to PHP, but also the HTML under it. I have every confidence that I am doing (not doing) something silly.

I start my sequence of panels with a straight HTML that passes a user name and password to a logon program that is to begin the session and progress on. The idea is that I want to preserve the ID and PWD as session data after verifying the correct ID and password. Code of the logon program follows:

Code: Select all

<?php
session_start(); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtmll/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="eng">
<head>
<title>Poka Lambro Maps and Numbers</title>
<style type="text/css" media="screen">
	@IMPORT url("map.css");
</style>
</head>
<body>
<h1 align="center">
<img border="0" src="OfficialPokaLogocropped.jpg"
	align="top"
	width="400" 
	height="50"
	alt="Poka Lambro Telephone">
<br />
Poka Lambro Maps and Map Numbers
</h1>
<h2 align="center">Results of your sign on</h2> 
<div align=center>
<?php
$userid = strtoupper($_POST["userid"]);
$password = $_POST["password"];
/* The user ID's on the 400 must be upper case  */
/* Connect to server Server name is seen with WRKRDBDIRE cmd */
$db = "S10D2BDB";
$options = array("i5_lib"=>"POKADDR911",
				"i5_naming"=>DB2_I5_NAMING_ON,
				"i5_commit"=>DB2_I5_TXN_NO_COMMIT,
				"cursor"=>DB2_SCROLLABLE);
/*  The connect is to certify the USERID and Password for later use */
$i5 = db2_connect($db,$userid,$password,$options);	
if (!$i5) {
	echo db2_conn_errormsg();
	print("Problems connecting to the database");
	print('<form name="input" action="index.htm" />'.'<br />');
	print('<input type="submit" value="return" />'.'<br />');
	session_destroy();
	}
else {
	print('Good Login'."<br />");
	$_SESSION['userid'] = $userid;
	$_SESSION['password'] = $password;
  	print($_SESSION['userid']."<br />");   
  	print($_SESSION['password']."<br />");
	Print('<form name="input" action="startmap.php" />' .
		'<br />');
	print('<input type="submit" value="continue" />'.'<br />');
	}
db2_close($i5);	
?>
</form>
</div>
</body>
</html>
The results indicate that I have successfully signed on. The "continue" box does take me to the "startmap.php" panel. On that panel, I can print the session name, but not the session id or UserID or Password that I had hoped to pass as session data. My hope here is that someone's eyes will see the silly mistake I am making. After the code I will paste in the session control part of the PHP.ini. Code follows:

Code: Select all

<?php
session_name();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtmll/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="eng">
<head>
<title>Poka Lambro Maps and Numbers</title>
<style type="text/css" media="screen">
	@IMPORT url("map.css");
</style>
</head>
<body>
<h1 align="center">
<img border="0" src="OfficialPokaLogocropped.jpg"
	align="top"
	width="400" 
	height="50"
	alt="Poka Lambro Telephone">
<br />
Poka Lambro Maps and Map Numbers
</h1>
<h2 align="center">Pick a function from the array of choices</h2> 
<div align=center>
<?php 
print('Session name: '.session_name().'<br />');
print('Session ID: '.session_id().'<br />');
print('UserID: '.$_SESSION['userid'].'<br />');
print('Password: '.$_SESSION['password'].'<br />');
?>
	<table id="choices" title="Exchanges" border="2">
	<tr>
		<th>Exchange</th>
		<th>Name</th>
		<th>By Map Grid</th>
		<th>By Address</th>
		<th>View Map</th>
		<th>Update 911</th>
		<th>Add 911</th>
	</tr>	
<?php
	crttr ("327","Fletcher Carter");
	crttr ("387","Seagraves");
	crttr ("428","O Donnell");
	crttr ("439","Aten");
	crttr ("462","Patricia");
	crttr ("465","West Lakes");
	crttr ("487","Loop");
	crttr ("489","Punkin Center");
	crttr ("497","Hatch");
	crttr ("522","Wheatley"); 
	crttr ("561","Tahoka");
	crttr ("585","Ausborne");
	crttr ("645","Nelms");
	crttr ("755","Union");
	crttr ("756","Gail");
	crttr ("924","New Home");
	crttr ("990","Post");
	crttr ("996","Southland") ;
	return;	
	
	function crttr($trnum, $trname) 
	{
//  	$trnum string;
//  	$trname string;
	echo "<tr>";
	echo "<td>" . $trnum . "</td>";
	echo "\n";
	echo "<td>" . $trname . "</td>";
	echo "\n";
	echo "<td class=\"enrty\"> <a href=\"mapgrid911.php?exchg=" . $trnum . "\" target=\"_self\">" . "Read 911" . "</a></td>";
	echo "\n";
	echo "<td class=\"enrty\"> <a href=\"address911.php?exchg=" . $trnum . "\" target=\"_self\">" . "Read 911" . "</a></td>";
	echo "\n";
	echo "<td class=\"enrty\"> <a href=\"serverinfo.php\" target=\"_blank\">" . "View Maps" . "</a></td>";
	echo "\n";
	echo "<td class=\"enrty\"> <a href=\"sqltapes2.php\" target=\"_blank\">" . "Update Records" . "</a></td>";
	echo "\n";
	echo "<td class=\"enrty\"> <a href=\"sqltapescnt2.php\" target=\"_blank\">" . "Add records" . "</a></td>";
	echo "\n";
	echo "</tr>";
	echo "\n";
	} 
?>
</table>
</div>
</body>
</html>

[Session]
session.save_handler = files
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

chris_hird
Posts: 171
Joined: Fri Apr 10, 2009 12:41 am
Location: Toronto
Contact:

Re: Newbie - Session support does not work for me

Post by chris_hird » Mon Apr 12, 2010 11:51 pm

You need session_start() in both files..

Chris..
Shield Advanced Solutions Ltd
Home of JobQGenie and the Receiver Apply Program
http://www.shield.on.ca/Blog

lundbergrd
Posts: 2
Joined: Fri Apr 09, 2010 4:44 pm

Re: Newbie - Session support does not work for me

Post by lundbergrd » Tue Apr 13, 2010 2:52 pm

Thanks. I am past this hurdle. As the only person here coding, it is very easy to get hung on a detail.

Post Reply