i have a project of nearly consisting of 10-15 session vars. so now i want know how much size does they occupy but i never find a way... so how to know how much space they occupy.? or else what are the factors affecting ..? and in best ,avg, worst case scenarios..? what if in the case of session multidimensional arrays?
if not may know how much space does this occupy..? how to reduce it?
<?php
session_start();
/*
if(isset($_SESSION['processing'])){
if($_SESSION['processing']==1)
{
$_SESSION['processing']=0;
}
else
{
header('Location: search1.php');
}
}
else
{
header('Location: search1.php');
}
*/
if($_SESSION['error']==0)
{
if(isset($_SESSION['tresults']))
{
$text_results=$_SESSION['tresults'];
if ($text_results<100)
{
$_SESSION['error']=5;
}
else
{
//sufficient results
}
} // if no result was found
}
//$_SESSION['tresults']=0;
$bannedkeywords = array("long list of keywords");
if(isset($_SESSION['searchedquery']))
{
$string=$_SESSION['searchedquery'];
}
else
{
$string="something";
}
$encode = array(
'/(\d+?)\.(\d+?)/' => '\\1DOT\\2',
'/(\d+?),(\d+?)/' => '\\1COMMA\\2',
'/(\d+?)-(\d+?)-(\d+?) (\d+?):(\d+?):(\d+?)/' => '\\1DASH\\2DASH\\3SPACE\\4COLON\\5COLON\\6'
);
foreach ($encode as $regex => $repl) {
$string = preg_replace($regex, $repl, $string);
}
preg_match_all('/\w+/', $string, $matches);
$decode = array(
'search' => array('DOT', 'COMMA', 'DASH', 'SPACE', 'COLON'),
'replace' => array('.', ',', '-', ' ', ':' )
);
foreach ($matches as $k => $v) {
$matches[$k] = str_replace($decode['search'], $decode['replace'], $v);
}
$bquery=count($matches, COUNT_RECURSIVE);
$bquery=$bquery-1;
$result = array_udiff($matches[0], $bannedkeywords, 'strcasecmp');
print_r($result);
$aquery=count($result, COUNT_RECURSIVE);
if($aquery==$bquery)
{
//query is clean
}
else
{
$_SESSION['error']=6;
}
if(!isset($_SESSION['searched']['one']))
{
$_SESSION['searchednumber']=0;
$_SESSION['searched']['one']=Array();
$_SESSION['searched']['two']=Array();
$_SESSION['searched']['three']=Array();
$_SESSION['searched']['four']=Array();
$_SESSION['searched']['five']=Array();
$_SESSION['searched']['six']=Array();
$_SESSION['searched']['seven']=Array();
$_SESSION['searched']['eight']=Array();
$_SESSION['searched']['nine']=Array();
$_SESSION['searched']['ten']=Array();
}
else
{
$_SESSION['searchednumber']=$_SESSION['searchednumber']+1;
}
$compare=$matches[0];
foreach ($_SESSION['searched']['one'] as $k => $v)
{
$compare[0] = array_udiff($compare[0], $_SESSION['searched'][$k], 'strcasecmp');
}
$n=$_SESSION['searchednumber'];
$p=$n%10;
$_SESSION['searched'][$p]=$compare[0];
echo "going well";
print_r($compare);
?>
thank you... :)