473,549 Members | 2,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I keep data for users that are not logged in yet

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?
Oct 11 '06 #1
2 2084
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["visitornam e"] = $MyReceivedName ;

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

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
Oct 11 '06 #2
>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.
You need a way to identify users from each other. Popular ways
for this include:

1. Assign a semi-permanent login ID that the users enter.
2. Use PHP sessions, which works for the duration of a session.
3. Use a cookie to store a temporary identifier. This method often
ends up being a "poor man's PHP sessions", but with real sessions
most of the work is already done.

WHY don't you want to put users in the database? It's pretty much
required for (1) and (3), and I generally prefer to use a PHP
session handler that puts session data in a database. It's much
easier to clean up than a directory that gets large (and therefore slow)
too quickly).
An IP address is *NOT* a good way to track users. Imagine an office with
a NAT router and a single public IP. You want all users in that office
to see each other's job selections? This is a great way to get your
users fired.
>2nd, What is the best way to do this. Session variables? A session array?
Use $_SESSION[]. How you organize that data depends a lot on your
application. Putting an array in $_SESSION['selection_list '] is
one way of collecting a list of selected jobs.
>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?
Different (simultaneous) users can share the same IP address.
The same user can have a different IP address on every hit (load-shared
proxies. I believe this includes AOL).
>$userLevel = "Guest"
$time = time();
$rememberIte m = 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.
Oct 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4445
by: d.schulz81 | last post by:
Hi all, We have about 10 different domains that are linked very closely and we want to identify and keep track of every single user that surfs our websites by the use of sessions. The problem is how to keep track of the session ID across domains. - cookies don't work because not acepted by 40 % of or users and cookies don't work across...
4
1430
by: Alex | last post by:
Dear netters, We are looking to build a SQL Server database that will be hooked up to a Web server (WebLogic or a .NET). The database will house data for multiple customers, and the requirement is to have no customer see other customer data. Web server will be responsible for authenticating users (ids and passwords will be maintained...
4
2739
by: Guadala Harry | last post by:
Is there any way for one Session to remove and update objects in another Session? I seriously doubt it, but thought I'd ask. Here's why: I have some data that is unique per user (or per session - similar to "welcome back, Jim" after Jim logs in) and consumed across multiple pages. This "per user" data lives in a database, so toward improving...
5
3015
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I need to send data from my server via the post method to the payment server. The payment server does not run asp.net. I dont know what they run. The...
2
1502
by: dhnriverside | last post by:
Hi guys I'm trying to create an updated list of which of my AD users are logged onto each computer - there's about 29 computers and we use hotdesking! I'm using Windows Integrated Authentication, so I know who the user is, and I obviously know the Workstation name they are on. My theory is that I could put something in Session_Start to...
6
5652
by: laredotornado | last post by:
Hi, When a user logs into our site, we create a session variable to denote the session is active and another to denote who is logged in. Once the user closes the browser and re-opens it, the session is destroyed and the variables are gone. How can I keep the session alive for 24 hours even if the user closes and re-opens the browser?
8
3733
by: Mike P | last post by:
What would be the best way of counting the number of users who are currently logged on to a website? I am making the users login against a database of valid users. Would the best way be to add a bool field to the table and set each user to 1 if they are logged in, and 0 if they are not logged in? *** Sent via Developersdex...
7
1593
by: Garry Freemyer | last post by:
I've researched this question on internet, and I've tried a number of things I found to no avail to solve this problem... I work for a company using Visual Studio 2003 to maintain a website for realtors. This webside allows a realtor to fill out a series of forms to get market analysis among other involved stuff. There is a lot of data...
13
6717
by: snowinfo | last post by:
Hi all, any way to count the number of users i have logged into my site? any help/code appreciated, craig
0
7459
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7726
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7819
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5377
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5097
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3488
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1953
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.