|
Posted by Jon Slaughter on 05/19/07 03:26
BTW, heres what I'm doing now,
Probably doesn't make much sense but if you look at the bottom of the page
you'll see how I add cookies into the form. After a user has clicked on a
button, the cookies there will be added. I just have to add the ability for
dynamic data of the cookies which I'll do tomorrow.
Essentially what this creates is a self contained paged. The line
if (isset($_SESSION['CALLBACKURL']) & !empty($_SESSION['CALLBACKURL']))
determines if its suppose to set the cookies or not and if so then does it
and then moves onto the next page. The code I have is working fine now but
probably is pretty buggy. Once I implement the dynamic code for the cookies
I'll post the code and see if anyone is interested in it and provide some
working examples. Right now the only page is the one below and it sets and
removes cookies. There are no other pages it links too.
you can goto to see it in action
http://www.jonslaughter.com/Index.php
The only pages on the site are Weblogin.php and Index.php. Weblogin only
holds the class.
<?php
session_start();
error_reporting(E_ALL); ini_set('display_errors','1');
ini_set('display_startup_errors','1'); ini_set('log_errors','1');
ini_set('display_startup_errors','1');
@require_once($_SERVER['DOCUMENT_ROOT'].'/Scripts/WebLogin.php');
$login = new WebLogin();
if (isset($_SESSION['CALLBACKURL']) & !empty($_SESSION['CALLBACKURL']))
{
$url = $_SESSION['CALLBACKURL'];
$login->SetCookies();
session_destroy();
unset($_SESSION);
unset($_COOKIE);
$url = '/Index.php';
echo '<meta content="0; URL='.$url.'" http-equiv="Refresh" />';
exit();
}
$login->DecodeCookies();
if (empty($_COOKIE) | !isset($_COOKIE))
{
echo "<br />No Cookies<br />\n";
}
else
{
echo "<br />Displaying Cookies<br />\n";
foreach($_COOKIE as $key => $val)
{
echo " ".$key." =>
".htmlentities(serialize($val))."<br />\n";
}
}
$login->StopDB();
?>
<html>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label>Cookie Name: </label><input name="CookieName" value="Jo" type="text"
/><br />
<label>Cookie Data: </label><input name="CookieData" value="Blow"
type="text" /><br />
<input name="FormAction" type="submit" value="Add Cookie">
</form>
<?php $login->AddCookieP('Add Cookie', '/ShowCookies.php/', 'CookieName',
'CookieData', array('location' => '/')); ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label>Cookie Name: </label><input name="CookieName" value="Jo" type="text"
/><br />
<input name="FormAction" type="submit" value="Delete Cookie">
</form>
<?php $login->DeleteCookieP('Delete Cookie', '/ShowCookies.php/',
'CookieName'); ?>
</body>
</html>
[Back to original message]
|