PHP data persistence without forms or GET methods?

PHP data persistence without forms or GET methods?

am 22.04.2008 16:06:01 von sebastiangarth

I need to be able to make a variable persistent between page
invocations without submitting a form or sending it as a name-value
pair in the URL. Another requirement I have is that I can't store the
data in a cookie or a file either. Are there any solutions to this
problem?

Re: PHP data persistence without forms or GET methods?

am 22.04.2008 16:11:45 von Erwin Moller

sebastiangarth@gmail.com schreef:
> I need to be able to make a variable persistent between page
> invocations without submitting a form or sending it as a name-value
> pair in the URL. Another requirement I have is that I can't store the
> data in a cookie or a file either. Are there any solutions to this
> problem?

Well, SESSION is the way to go.

You were not completely clear if a sessionid is allowed in the
url/form/cookie (it can be passed around via all 3).

read more here:
http://nl2.php.net/manual/en/book.session.php

If that is no option I cannot think of anything else.
This is what sessions were made for.

Regards,
Erwin Moller

Re: PHP data persistence without forms or GET methods?

am 22.04.2008 16:55:40 von sebastiangarth

Thank you very much.

Cheers,
- Sebastian

Re: PHP data persistence without forms or GET methods?

am 22.04.2008 17:20:29 von sebastiangarth

I am assuming then that there is no way to simulate that a form has
been submitted (ie: by emedding a form with a hidden element into an
anchor tag, for instance)?

Re: PHP data persistence without forms or GET methods?

am 22.04.2008 17:29:29 von Erwin Moller

sebastiangarth@gmail.com schreef:
> I am assuming then that there is no way to simulate that a form has
> been submitted (ie: by emedding a form with a hidden element into an
> anchor tag, for instance)?
>

Hi Sebastian,

I cannot follow what it is that you want to accomplish.
You said earlier you do not want to use a form to propagate information.
Now you suggest to use a form to do excactly that.

Please state your problem clearly, maybe we can help.
Like this I am shooting in the dark. :-/

Regards,
Erwin Moller

Re: PHP data persistence without forms or GET methods?

am 22.04.2008 18:28:55 von sebastiangarth

> You said earlier you do not want to use a form to propagate information. Now you suggest to use a form to do excactly that.

The problem is that most of the navigation by the user will be via
links. I could of course imbed the variables in the URL but I would
prefer not to send some of that information 'in the clear'. Ideally, I
would like to send them along as a post request, but I don't see how
this is possible without using forms.

Re: PHP data persistence without forms or GET methods?

am 22.04.2008 20:30:47 von sebastiangarth

Well, anyway, your suggestion to use sessions seems like the best
option. Thank you for your time and input.

Regards,
- Sebastian

Re: PHP data persistence without forms or GET methods?

am 22.04.2008 20:57:08 von Jerry Stuckle

sebastiangarth@gmail.com wrote:
>> You said earlier you do not want to use a form to propagate information. Now you suggest to use a form to do excactly that.
>
> The problem is that most of the navigation by the user will be via
> links. I could of course imbed the variables in the URL but I would
> prefer not to send some of that information 'in the clear'. Ideally, I
> would like to send them along as a post request, but I don't see how
> this is possible without using forms.
>

It's not.

As Erwin said - use sessions.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: PHP data persistence without forms or GET methods?

am 23.04.2008 02:29:23 von Courtney

sebastiangarth@gmail.com wrote:
> I am assuming then that there is no way to simulate that a form has
> been submitted (ie: by emedding a form with a hidden element into an
> anchor tag, for instance)?
>


If you set hidden variables and SUBMIT - via javascript if necessary - a
pseudo form, then you can pass post variables.

What is wrong with a form anyway?

Re: PHP data persistence without forms or GET methods?

am 23.04.2008 02:32:24 von Courtney

sebastiangarth@gmail.com wrote:
>> You said earlier you do not want to use a form to propagate information. Now you suggest to use a form to do excactly that.
>
> The problem is that most of the navigation by the user will be via
> links. I could of course imbed the variables in the URL but I would
> prefer not to send some of that information 'in the clear'. Ideally, I
> would like to send them along as a post request, but I don't see how
> this is possible without using forms.

Us a form method=post and make the URLS and onclick=submit() type
javascript function.

You can have a separat javascript function set up wahetver cvariable you
like depending on waht is clicked.

Mind you, I simply use URLS and get variables mainly as they are a
convenience to the user, not an absolute restriction.

If they try to access things outside the scope of whats allowed, they
get a rude message back: thats pure data validatin on teh get variables.
\

Re: PHP data persistence without forms or GET methods?

am 23.04.2008 02:33:13 von Courtney

Jerry Stuckle wrote:
> sebastiangarth@gmail.com wrote:
>>> You said earlier you do not want to use a form to propagate
>>> information. Now you suggest to use a form to do excactly that.
>>
>> The problem is that most of the navigation by the user will be via
>> links. I could of course imbed the variables in the URL but I would
>> prefer not to send some of that information 'in the clear'. Ideally, I
>> would like to send them along as a post request, but I don't see how
>> this is possible without using forms.
>>
>
> It's not.
>
> As Erwin said - use sessions.
>
Which tend to use cookies or GET variables to maintain state anyway.

Re: PHP data persistence without forms or GET methods?

am 23.04.2008 03:02:27 von Jerry Stuckle

The Natural Philosopher wrote:
> Jerry Stuckle wrote:
>> sebastiangarth@gmail.com wrote:
>>>> You said earlier you do not want to use a form to propagate
>>>> information. Now you suggest to use a form to do excactly that.
>>>
>>> The problem is that most of the navigation by the user will be via
>>> links. I could of course imbed the variables in the URL but I would
>>> prefer not to send some of that information 'in the clear'. Ideally, I
>>> would like to send them along as a post request, but I don't see how
>>> this is possible without using forms.
>>>
>>
>> It's not.
>>
>> As Erwin said - use sessions.
>>
> Which tend to use cookies or GET variables to maintain state anyway.
>

Ah, I see you're showing your (lack of) intelligence again with another
stoopid comment from you. Read the whole thread, not just a couple of
posts.

Yes, PHP uses cookies or, if cookies are disabled, can use a GET
variable. But that is only for the session id, not for the actual data.
And by using a cookie, the session id doesn't need to be sent in the
GET string - which is what the op is trying to avoid.



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: PHP data persistence without forms or GET methods?

am 23.04.2008 09:18:25 von Erwin Moller

The Natural Philosopher schreef:
> sebastiangarth@gmail.com wrote:
>>> You said earlier you do not want to use a form to propagate
>>> information. Now you suggest to use a form to do excactly that.
>>
>> The problem is that most of the navigation by the user will be via
>> links. I could of course imbed the variables in the URL but I would
>> prefer not to send some of that information 'in the clear'. Ideally, I
>> would like to send them along as a post request, but I don't see how
>> this is possible without using forms.
>
> Us a form method=post and make the URLS and onclick=submit() type
> javascript function.
>
> You can have a separat javascript function set up wahetver cvariable you
> like depending on waht is clicked.
>
> Mind you, I simply use URLS and get variables mainly as they are a
> convenience to the user, not an absolute restriction.
>
> If they try to access things outside the scope of whats allowed, they
> get a rude message back: thats pure data validatin on teh get variables.
> \

I don't think this is general good advise.
This method is based on JavaScript, which isn't always available.
Session are much easier, and do not depend on JavaScript.

PHP even helps, if configured that way, to add the phpsessionid to
cookie, formelements (as hidden), or url encoded in the url.
No need to do this yourself.

Sebastian, just have a look at how sessions work.
If you are on PHP version >4 (and who uses 3 in these days?) then
sessionsupport is easy and reliable.
You can even use the autostart session simply by editting your php.ini.
Read more here:
http://nl2.php.net/manual/en/session.configuration.php#ini.s ession.auto-start


Regards,
Erwin Moller

Re: PHP data persistence without forms or GET methods?

am 23.04.2008 13:31:23 von Courtney

Jerry Stuckle wrote:
> The Natural Philosopher wrote:
>> Jerry Stuckle wrote:
>>> sebastiangarth@gmail.com wrote:
>>>>> You said earlier you do not want to use a form to propagate
>>>>> information. Now you suggest to use a form to do excactly that.
>>>>
>>>> The problem is that most of the navigation by the user will be via
>>>> links. I could of course imbed the variables in the URL but I would
>>>> prefer not to send some of that information 'in the clear'. Ideally, I
>>>> would like to send them along as a post request, but I don't see how
>>>> this is possible without using forms.
>>>>
>>>
>>> It's not.
>>>
>>> As Erwin said - use sessions.
>>>
>> Which tend to use cookies or GET variables to maintain state anyway.
>>
>
> Ah, I see you're showing your (lack of) intelligence again with another
> stoopid comment from you. Read the whole thread, not just a couple of
> posts.
>
> Yes, PHP uses cookies or, if cookies are disabled, can use a GET
> variable. But that is only for the session id, not for the actual data.
> And by using a cookie, the session id doesn't need to be sent in the
> GET string - which is what the op is trying to avoid.
>
>
>
It's not clear as to what his real issue actually is.

The original post said maintaining a state without use of post get or
cookie variables.

Saying 'then use sessions' masks the fact that sessions indeed use
cookies, post or get variables to maintain states.

Re: PHP data persistence without forms or GET methods?

am 23.04.2008 18:56:00 von Jerry Stuckle

The Natural Philosopher wrote:
> Jerry Stuckle wrote:
>> The Natural Philosopher wrote:
>>> Jerry Stuckle wrote:
>>>> sebastiangarth@gmail.com wrote:
>>>>>> You said earlier you do not want to use a form to propagate
>>>>>> information. Now you suggest to use a form to do excactly that.
>>>>>
>>>>> The problem is that most of the navigation by the user will be via
>>>>> links. I could of course imbed the variables in the URL but I would
>>>>> prefer not to send some of that information 'in the clear'. Ideally, I
>>>>> would like to send them along as a post request, but I don't see how
>>>>> this is possible without using forms.
>>>>>
>>>>
>>>> It's not.
>>>>
>>>> As Erwin said - use sessions.
>>>>
>>> Which tend to use cookies or GET variables to maintain state anyway.
>>>
>>
>> Ah, I see you're showing your (lack of) intelligence again with
>> another stoopid comment from you. Read the whole thread, not just a
>> couple of posts.
>>
>> Yes, PHP uses cookies or, if cookies are disabled, can use a GET
>> variable. But that is only for the session id, not for the actual
>> data. And by using a cookie, the session id doesn't need to be sent
>> in the GET string - which is what the op is trying to avoid.
>>
>>
>>
> It's not clear as to what his real issue actually is.
>
> The original post said maintaining a state without use of post get or
> cookie variables.
>
> Saying 'then use sessions' masks the fact that sessions indeed use
> cookies, post or get variables to maintain states.
>

It looked to me he wanted to avoid using a form because he's using links
instead. He didn't want to put the data in the GET url, which is
understandable. And he didn't want to save the data in a cookie.

You have to use (at least) one of the three to pass information. But
you don't have to hold the data in the cookie - you can use the session
for that and only pass the session id in the cookie.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: PHP data persistence without forms or GET methods?

am 23.04.2008 21:19:11 von sebastiangarth

>> Us a form method=post and make the URLS and onclick=submit() type
javascript function.

As Moller pointed out, Javascript isn't always available, and if it is
indeed disabled the application becomes essentially useless! At any
rate, sessions turned out to be exactly what I needed. Thank you all
for your help.

Re: PHP data persistence without forms or GET methods?

am 24.04.2008 09:01:08 von Erwin Moller

sebastiangarth@gmail.com schreef:
>>> Us a form method=post and make the URLS and onclick=submit() type
> javascript function.
>
> As Moller pointed out, Javascript isn't always available, and if it is
> indeed disabled the application becomes essentially useless! At any
> rate, sessions turned out to be exactly what I needed. Thank you all
> for your help.

Good choiche.
Session are really extremely handy.
Once you know your way around with session, you won't look back at other
options. ;-)

Good luck.

Regards,
Erwin Moller