Discussion Locked

Alternative to session variable, cookies

0 helpful
13 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I want to know is there any other way to retain the information of a user without using session variables, cookies, querystring and hidden form fields in PHP i.e. is there any alternative to session variables, cookies, querystring and storing values in hidden form fields?

13 replies

by Member 25308556

Hi,
Sorry to tell you, as far as I know there are no alternatives if you want to retain user-information across link-clicks.
But - if you only have a very few, and preferably controlled (by IP) users, or you know their IP-address, you might use GLOBAL post variables posted by the browser at each page request as an identifier, and store the session data/information in a database. This works fine until you have lots of users, or several users are behind the same proxy, or until one user uses more than one window/tab to browse the site (this may /may not make a problem for you, depending on the information retained...)
Hope this helps :)

Kai

by mr.arvind.sharma

I know that I can store the information in the database or make a txt file and store the information relativ to each form and user that is possible if I have few users or what I can do is delete the records or files after a certain period of inactivity by a user. But I am looking for something else if its there.

by jaqui

simply put:
using these is a means of maintaining state in the stateless web environment.
even doing the database route mean having some means of identifying each user, before they "login" to be able to get the data about them stored in the db.

so, no, there is no way to completely avoid using one of these to maintain state.

the way to do so with ease of file removable is to work with the sessions, as after the session expires all session specific data is purged by default.

by Member 25308556

May I ask you for more details about what you want to save across pageviews, how you want to use it and what is your server/script system?
If you try to explain in more details what you are trying to do, it might be easier for us to give you a better suited answer :)

Kai

by mr.arvind.sharma

Thanks Kairoer,
Suppose I am having 3-4 forms to gather the information from users. whenever a user fills a form and goes to next and then to next form and then comes back to first form I want to retain the information filled in by that user on all the forms filled in by the user.
I am using PHP, MySQL, Apache.

by apotheon

You're out of options for keeping track of a client across multiple sessions.

PHP gets client data from
1. cookies
2. HTTP headers
3. URLs
4. GET and POST

The only other way to make that work is by way of IP or MAC address connection state. PHP doesn't allow any way to manage identification by MAC address: you'd have to use something else to do it. IP addresses can be handled by harvesting from HTTP headers, using the $REMOTE_ADDR environment valuable, but then you're just replicating the use of session data.

What the heck could be your reason for not using session data, cookies, query strings, or forms?

by hughpoynor

There is always at least one more way to do anything. These suggestions are untried but seem obvious to me initially. 1. Have php get the user IP address on each page -- use the IP as a key to a mySQL record that holds the info you want to keep across pages, 2. ditto but without mySQL using fwrite() and fread() and your own little ISAM lookup.

by hughpoynor

There is always at least one more way to do anything. These suggestions are untried but seem obvious to me initially. 1. Have php get the user IP address on each page -- use the IP as a key to a mySQL record that holds the info you want to keep across pages, 2. ditto but without mySQL using fwrite() and fread() and your own little ISAM lookup.

by mac1ne

sorry I can't offer another solution, BUT I can warn you that using (what you think is) a user's IP addresses is NOT reliable....they can change across page requests, be faked / blocked, can be shared by multiple users coming from a proxy server, etc.

by Member 25308556

Hi :)

please look at my first answer - it says exactly what later replies says.
So - to your quick-fix. You could use JavaScript (if allowed on the client) to gather the information the clientside. When you have gathered all the information you want, you can do client-side verifications and other data-altering stuff, then you submit all the information to the server - that is - if you want the information on the server ;)

By using a mix of Javascript and dhtml and styles, you can even do all this with only two requests to the server - first when the client initiate&download the form(s), and then optionally a second time when the client posts the info back to the server.

Please let me know if this might solve your problem.
Other variants might be using dynamically updated pages, where you use one part of the page to do the communication with the server.
Another way would be using Flash or similiar web-related technologies.

Then a question - why do you require to do this without the sessioning?

Kai :)

by Member 25308556

Hi :)

please look at my first answer - it says exactly what later replies says.
So - to your quick-fix. You could use JavaScript (if allowed on the client) to gather the information the clientside. When you have gathered all the information you want, you can do client-side verifications and other data-altering stuff, then you submit all the information to the server - that is - if you want the information on the server ;)

By using a mix of Javascript and dhtml and styles, you can even do all this with only two requests to the server - first when the client initiate&download the form(s), and then optionally a second time when the client posts the info back to the server.

Please let me know if this might solve your problem.
Other variants might be using dynamically updated pages, where you use one part of the page to do the communication with the server.
Another way would be using Flash or similiar web-related technologies.

Then a question - why do you require to do this without the sessioning?

Kai :)

This discussion is closed to new replies.