For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > June 2006 > tracking a session without using sessions or cookies









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author tracking a session without using sessions or cookies
frothpoker

2006-06-25, 6:58 pm

Guys,

I have a couple of issues which I am hoping you can provide guidance
on...

First one:- Is there any way to retain the $_POST values when a user
navigates between pages without using <form method = 'post'>

I want to be able to track the user from one page to another to provide
customised content. I could make all navigation buttons as forms but
its a bit of a pain in the proverbials

Second one, which is related to the first:-

I have submitted and validated data in a form where the action is
$PHP_SELF.

I need to insert a record into a database.

The user will have selected a venue which may have more than one event.
The validation checks the database for the number of events and if
there is only one, chooses that as the default. If there is more than
one then it needs to display another form to select the correct event
but I obviously need to pass all the $_POST values through this new
form so that I can insert it into the database... Should I just
iterate through the $_POST array with hidden fields on the form, or can
I pass the whole array through while adding array elements to it?

David Haynes

2006-06-25, 6:59 pm

frothpoker wrote:
> Guys,
>
> I have a couple of issues which I am hoping you can provide guidance
> on...
>
> First one:- Is there any way to retain the $_POST values when a user
> navigates between pages without using <form method = 'post'>
>
> I want to be able to track the user from one page to another to provide
> customised content. I could make all navigation buttons as forms but
> its a bit of a pain in the proverbials

Use a SESSION to store the values you want to remember.

> Second one, which is related to the first:-
>
> I have submitted and validated data in a form where the action is
> $PHP_SELF.
>
> I need to insert a record into a database.
>
> The user will have selected a venue which may have more than one event.
> The validation checks the database for the number of events and if
> there is only one, chooses that as the default. If there is more than
> one then it needs to display another form to select the correct event
> but I obviously need to pass all the $_POST values through this new
> form so that I can insert it into the database... Should I just
> iterate through the $_POST array with hidden fields on the form, or can
> I pass the whole array through while adding array elements to it?


Again SESSION would be your friend here.

Think of it this way. The browser may pass data to the php program using
either POST or GET methods. PHP programs may pass data using the SESSION
to other PHP programs.

The 'short cut' of using PHP_SELF and the browser-passed variables is
just that - a short cut.

-david-

R. Rajesh Jeba Anbiah

2006-06-25, 6:59 pm

frothpoker wrote:
<snip>
> First one:- Is there any way to retain the $_POST values when a user
> navigates between pages without using <form method = 'post'>
>
> I want to be able to track the user from one page to another to provide
> customised content. I could make all navigation buttons as forms but
> its a bit of a pain in the proverbials

<snip>

There are couple of hacks I'm thinking like hooking onClick via
JavaScript using event:Selectors/Prototype. But, I guess there might be
better elegant solution when you tell us what exactly is your problem.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

David Haynes

2006-06-25, 6:59 pm

New response since I missed the desire not to use sessions or cookies.

Generate a unique id for the session and use that as the primary key
into a database where you store the variable values. Include the unique
id in each browser page and pass it back with each form.

-david-

Paul Lautman

2006-06-25, 6:59 pm

Krustov wrote:
> <comp.lang.php>
> <frothpoker>
> <25 Jun 2006 07:45:21 -0700>
> <1151246721.161660.184980@i40g2000cwc.googlegroups.com>
>
>
> Dont know about guidance - but couldnt you use the users ip address
> coverted from 123.123.123.123 to 123_123_123_123.txt and append the
> text to a flatfile assuming you have some sort of track.php include
> file at the top of each page .
>
> With perhaps 123_123_123_123_nav.txt being used when wanted etc .


But the user's ip address may not be unique.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com