You are here: Re: How can I keep data for users that are not logged in yet « PHP Programming Language « IT news, forums, messages
Re: How can I keep data for users that are not logged in yet

Posted by Erwin Moller on 10/11/06 07:53

Don Hobson wrote:

> I am building a website and I want to allow users to do certain things
> without logging in. I would like to allow them to keep track of certain
> items, by adding them to a list.
>
> Like if they are viewing multiple job listings in Houston, they can add
> each job they care about to a list and when they are done looking at all
> the jobs, they can view the list of say, 10 jobs. They can print the list
> or email the list to themselves or someone else.
>
> 1st, what is the best way to track this user? IP address? I can have
> multiple guest users online at any given time. I don't want to put them in
> the database.
>
> 2nd, What is the best way to do this. Session variables? A session array?
>
> What kind of data structure can I setup?
>
> $visitorId = the ip address i get from $_SERVER['REMOTE_ADDR'] or should I
> just use a session_id that php provides? Is that good enough?
>
> $userLevel = "Guest"
> $time = time();
> $rememberItem = array();
>
> Every time a visitor checks the remember me checkbox next to a job, I will
> add that jobId to the $rememberItem session array.
>
> Then when they want to see all of the jobs they asked to remember, I will
> display a page that calls the database using each Id to display the title
> and other info about each job. Then the user can print the page.
>
> Is that the best way to do this?

Hi,

Long question.
Short answer: sessions

A session can be started by adding session_start() at the beginning of each
script.
You store values in a session like in any other associative array, like
this:
$SESSION["visitorname"] = $MyReceivedName;

and retrieve this value from another page like this:
echo $SESSION["visitorname"];

You can store about any value and also complete arrays in a session.

Read more at www.php.net, look up session.

Good luck,
Regards,
Erwin Moller

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация