php-windows Digest 23 Dec 2003 05:36:16 -0000 Issue 2053
Topics (messages 22417 through 22418):
Re: serialize and unserialize
22417 by: Svensson, B.A.T. (HKG)
Question about general web site layout
22418 by: Paul Menard
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Ignorant question:
You are doing unserialize() twice on the same entity.
Are you allowed to do that?
-----Original Message-----
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: 2003-12-21 21:37
Subject: [PHP-WIN] serialize and unserialize
Hello all i need a little help with serialize and unserialize
here is my code
<?php
session_start();
if(!isset($_COOKIE['data'])) { //Check to see
if cookie is there.
include("cookie_num.dat");
$y = "$password";
//Assign a special number for each
cookie.
$data = array('x' => 'cart', 'y' => $password);
session_register("y");
$var = serialize($data);
//$chksum = md5($data . md5('secret salt here'));
//$var = serialize(array($data,$chksum));
setcookie('data', $var, time() + 3600);
} else {
$var = unserialize($_COOKIE['data']); <---
list($data, $chksum) = $var;
if (md5($data . md5('secret salt here')) == $chksum)
{
// Data is valid
$data = unserialize($_COOKIE['data']); <---
list($y, $chksum) = $data;
$x = $data['x'];
$y = $data['y'];
session_register("y");
}
//session_register("y");
}
?>
the problem is when i try to pull it back out to use the number that is
generated by $password it gives me this error
Notice: unserialize(): Error at offset 9 of 118 bytes in c:\program
files\apache group\apache\htdocs\header.php on line 24
any ideas towards fixin this would be appreciated
--- End Message ---
--- Begin Message ---
Okay. This is not really a question specific to Windows. But here is goes.
I am looking for some 'Nest Practice' advice on how to layout my pages and config
files. By layout
I am not talking about the presentation of the page for the browser but instead the
layout of the
pages on disk.
Here is an example many sites have the home page in the root
(http://www.somesite.com/index.php
(html). This is the entry point to the site. The average site have a left nav menu
with links to
thinks like thier blob and maybe an 'About'. Most sites that use this type of layout
will link the
'About' to a sub-folder under the home as in http://www.somesite.com/about/index.php
(html).
Here is my point. On the 'About' I want to use the same header/footer and menu as on
the main
page. This can be handled via an include in the main page like:
<?php
include("config_inc.php");
?>
Question is on the 'About' section which is one level below the main in the disk
heirarchy, should
I start by just using the relative include path as in:
<?php
include("../config_inc.php");
?>
To me this provide a solution alright but not a clean solution. How does everyone else
accomlish
this in thier multi-page sites.
--- End Message ---