Thread: php sessions
View Single Post
Old 10-10-2007, 02:21 PM   #23 (permalink)
Rating: 0% (0)
Matthew King
Advancing Real Estate agent
 
Matthew King's Avatar
 
Join Date: Jul 2007
Posts: 95
Default

Quote:
Originally Posted by Almeria Property Place View Post
got it working fine now, only problem is it raises two points, can you delete individual references in the session? and how do you stop them being added twice?
To delete, its a bit cumbersome but here goes:

/delete.php?reference=123

Code:
$old = explode(',' $_SESSION['portfolio']);
$new = '';

foreach($old as $ref) {
   if ($ref != $_GET['reference']) {
      $new .= ',' . $ref;
   }
}

$_SESSION['portfolio'] = $new;

Header('Location: portfolio.php');
And to make sure duplicates aren't added:

Code:
  
   if (strpos($_SESSION['portfolio'], ',' . $_GET['reference']) !== false) {
      // put the code to add to the session here
   }
__________________
Real Estate Web Developer & SEO Consultant

www.costablancapropertyportal.com | Costa Blanca Property | Javea Property for sale

Last edited by Matthew King; 10-10-2007 at 02:23 PM. Reason: Changed $_SESSION['reference'] to $_SESSION['portfolio'] on the second code example.
Matthew King is offline   Reply With Quote
 

Spanish Real Estate Forum - Members newest adverts
CH5 New Villa Costa Azahar
A Castle in Spain
Costa Azahar Village House for sale
CHL Investment Opportunity Coasta Azahar
Cervera del Maestre Property