Home About Contact
Spanish Real Estate forum - Spanish property - Estate agents


Website design Find a website designer, discuss website designs and information about designing a property website... Also hosting reviews for those looking for a new host company or to express there opinion of other host companies...

Reply
Old 10-05-2007, 11:58 AM   #1 (permalink)
Rating: 0% (0)
Advancing Real Estate agent
 
Almeria Property Place's Avatar
 
Join Date: Jun 2007
Posts: 97
Send a message via Yahoo to Almeria Property Place Send a message via Skype™ to Almeria Property Place
Unhappy php sessions

hi can anyone point me to a good tutorial on sessions and php as most of the ones i find on the web are about using them with log ins, is it possible to just generate a random session id and then use this with all the pages, rather than setting variables.

confused
Almeria
__________________
Jeremy Lister
Almeria Property Place
www.almeriapropertyplace.com
www.albaniapropertyplace.com
jlister@almeriapropertyplace.com
00 34 950 333 465
Almeria Property Place is offline   Reply With Quote
Old 10-05-2007, 12:07 PM   #2 (permalink)
Rating: 0% (0)
Advancing Real Estate agent
 
Matthew King's Avatar
 
Join Date: Jul 2007
Posts: 95
Default

Hi Jeremy,

You can do this:

Code:
   <?php
      session_start();
      print(session_id());
   ?>
That gives you the unique session id. If you want to store variables, you call:
Code:
<?php $_SESSION['message'] = 'Hello World'; ?>
which you can then pull out again with:

Code:
<?= $_SESSION['message']; ?>
Just remember to call session_start(); before you start playing with it.

Hope that helps.
Matthew
__________________
Real Estate Web Developer & SEO Consultant

www.costablancapropertyportal.com | Costa Blanca Property | Javea Property for sale
Matthew King is offline   Reply With Quote
Old 10-05-2007, 12:23 PM   #3 (permalink)
Rating: 0% (0)
Advancing Real Estate agent
 
Almeria Property Place's Avatar
 
Join Date: Jun 2007
Posts: 97
Send a message via Yahoo to Almeria Property Place Send a message via Skype™ to Almeria Property Place
Talking sessions

ok thanks for that i will have a play around, can i then use this if i want the page user to be able to add a property reference to a type of portfolio that he can view later?
__________________
Jeremy Lister
Almeria Property Place
www.almeriapropertyplace.com
www.albaniapropertyplace.com
jlister@almeriapropertyplace.com
00 34 950 333 465
Almeria Property Place is offline   Reply With Quote
Old 10-05-2007, 12:58 PM   #4 (permalink)
Rating: 0% (0)
Advancing Real Estate agent
 
Matthew King's Avatar
 
Join Date: Jul 2007
Posts: 95
Default

Yes, you'd want something like this:

To add a property to portfolio:

e.g. /add.php?reference=1
Code:
    <?php
        session_start();
        $_SESSION['portfolio'] .= ',' . $_GET['reference'];
    ?>
Then to get the references back:

e.g. /portfolio.php

Code:
    <?php
        session_start();

        $references = explode(',' $_SESSION['portfolio']);

        foreach($references as $ref) {
            print($ref) . '<br />';
        }
    ?>
I haven't written any PHP properly for ages, so excuse me if there are any syntax errors there. Should give you a good starting point though.

Matthew
__________________
Real Estate Web Developer & SEO Consultant

www.costablancapropertyportal.com | Costa Blanca Property | Javea Property for sale
Matthew King is offline   Reply With Quote
Old 10-05-2007, 01:38 PM   #5 (permalink)
Rating: 0% (0)
Advancing Real Estate agent
 
Almeria Property Place's Avatar
 
Join Date: Jun 2007
Posts: 97
Send a message via Yahoo to Almeria Property Place Send a message via Skype™ to Almeria Property Place
Exclamation reference

where or how do i get the reference, direct from database?
__________________
Jeremy Lister
Almeria Property Place
www.almeriapropertyplace.com
www.albaniapropertyplace.com
jlister@almeriapropertyplace.com
00 34 950 333 465
Almeria Property Place is offline   Reply With Quote
Old 10-05-2007, 01:49 PM   #6 (permalink)
Rating: 0% (0)
Advancing Real Estate agent
 
Matthew King's Avatar
 
Join Date: Jul 2007
Posts: 95
Default

When reading from your database, include a link to the 'Add to Portfolio' page passing the property reference by querystring.

Then you'll need to select it from the db when you read the portfolio list, e.g. SELECT * FROM Property WHERE reference = $ref in the for loop.
__________________
Real Estate Web Developer & SEO Consultant

www.costablancapropertyportal.com | Costa Blanca Property | Javea Property for sale
Matthew King is offline   Reply With Quote
Old 10-05-2007, 01:53 PM   #7 (permalink)
Rating: 0% (0)
Advancing Real Estate agent
 
Almeria Property Place's Avatar
 
Join Date: Jun 2007
Posts: 97
Send a message via Yahoo to Almeria Property Place Send a message via Skype™ to Almeria Property Place
Exclamation every page?

does the session start go on every page of my site?
__________________
Jeremy Lister
Almeria Property Place
www.almeriapropertyplace.com
www.albaniapropertyplace.com
jlister@almeriapropertyplace.com
00 34 950 333 465
Almeria Property Place is offline   Reply With Quote
Old 10-05-2007, 02:16 PM   #8 (permalink)
Rating: 0% (0)
Advancing Real Estate agent
 
Matthew King's Avatar
 
Join Date: Jul 2007
Posts: 95
Default

Every page where you want to access the session.
__________________
Real Estate Web Developer & SEO Consultant

www.costablancapropertyportal.com | Costa Blanca Property | Javea Property for sale
Matthew King is offline   Reply With Quote
Old 10-09-2007, 11:21 AM   #9 (permalink)
Rating: 0% (0)
Advancing Real Estate agent
 
Almeria Property Place's Avatar
 
Join Date: Jun 2007
Posts: 97
Send a message via Yahoo to Almeria Property Place Send a message via Skype™ to Almeria Property Place
Default

Quote:
Originally Posted by Matthew King View Post
Yes, you'd want something like this:

To add a property to portfolio:

e.g. /add.php?reference=1
Code:
    <?php
        session_start();
        $_SESSION['portfolio'] .= ',' . $_GET['reference'];
    ?>
Then to get the references back:

e.g. /portfolio.php

Code:
    <?php
        session_start();

        $references = explode(',' $_SESSION['portfolio']);

        foreach($references as $ref) {
            print($ref) . '<br />';
        }
    ?>
I haven't written any PHP properly for ages, so excuse me if there are any syntax errors there. Should give you a good starting point though.

Matthew
i only seem to get the comma in the quote marks storing in the session, how do i send the actual reference number to the session? i have tried the inserting the url link instead of the comma but it doesnt like it.
__________________
Jeremy Lister
Almeria Property Place
www.almeriapropertyplace.com
www.albaniapropertyplace.com
jlister@almeriapropertyplace.com
00 34 950 333 465
Almeria Property Place is offline   Reply With Quote
Old 10-09-2007, 01:29 PM   #10 (permalink)
Rating: 0% (0)
Advancing Real Estate agent
 
Almeria Property Place's Avatar
 
Join Date: Jun 2007
Posts: 97
Send a message via Yahoo to Almeria Property Place Send a message via Skype™ to Almeria Property Place
Default got it!!!

got it to work, just need to find out out to enter each individual reference in a new row on a table instead of a new line.

thanks
__________________
Jeremy Lister
Almeria Property Place
www.almeriapropertyplace.com
www.albaniapropertyplace.com
jlister@almeriapropertyplace.com
00 34 950 333 465
Almeria Property Place is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +2. The time now is 04:06 AM.
Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Skin purchased from CompletevB
Inactive Reminders By Icora Web Design

Copyright 2008 © Spanish Real Estate Forum

Our / partners websites:



Forum Navigation
Spanish property for sale

Accreditation of International Real Estate Professionals


Costa Blanca forum

Alphashare - Real Estate management software

Free Spanish agent advertising for 1 year!


Forum Staff
Colin S
- Hamiltons of London

Homefinder
- Villaservers

andypropertyswapshop
- Property Swap Shop

gregor
- 123 Businesses for sale

top-tour-of-spain
- Top Tour of Spain

Girasol Homes
- Girasol Homes

wood1e
- En Casa Baleares
Areas in Spain
Partner Websites
English speaking jobs in Spain