How send $_SESSION vars to the server

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
hi at all

I'ld like to know if it is possible AND HOW IT IS POSSIBLE to insert a nre
value into a$_SESSION['variable'] and to refresh it without reloading the

Thank you very much

Re: How send $_SESSION vars to the server

Quoted text here. Click to load it

$_SESSION ['foo'] = 'bar';

Re: How send $_SESSION vars to the server

Paolo wrote:
Quoted text here. Click to load it

Not sure 'nre' was a typo or is a acronym . since i can't figure what
nre is i'll ignore it , If 'nre' means something please provide more info.

** Disclaimer :I am assuming that you want to send data to php set a
session variable  and make it seamless for the user.Just in case I'm
gonna go into a little explanation to make sure I'm being clear

In php Session data is stored on the server and never reaches the client
( browser ). The client only has the sessionid ( stored in a cookie )
that is used to relate to the data stored on the server.

..A little explanation..

Cookie data must be written in the headers before html output begins so
usually you limit how much is done to the data , and usually you have to
do it first.Can be complicated and requires careful planning.

Sessions different. Only the Sessionid is sent via headers, any data
changes are stored on the sever. You can change the data as much as you
want, right up to near when the script ends if you want to.

Now this happens all at the server end, and only while the script is
running, so if you have all the available data you can set a session
variable by doing ( You can do this as many times as you like while the
script is running. ) ;


This relies of data being obtained via a database , post (from a form)
or get ( variables passed in url ).This means that your php script
generates the output based on the information given.

Now if you want a seamless non-refresh style of page you need to look
into AJAX . You can use JavaScript to post data to your php scripts that
can manage the data in sessions then return changes to the main html if
required. This can happen as many times as needed and will be
transparent to the client.

If that is what you are after I suggest you start looking into AJAX via
Google and talking to a JavaScript newsgroup.

If I have gotten your question horridly wrong , please reply and explain

regards trookat

Re: How send $_SESSION vars to the server

Quoted text here. Click to load it

Will a javascipt invoked call to a php script set a cookie on the
users browser for the session? I thought you could only set cookies /
sessions in a page's header information.

Bill H

Re: How send $_SESSION vars to the server

Bill H wrote:
Quoted text here. Click to load it

php cannot send cookies via AJAX as the html headers need to be resent,
JavaScript could act as a in between to set cookies , however we are are
talking about sessions which is different. ( as explained in my reply )

SessionID cookie only needs to be set once and when authenticating ( to
prevent session fixation )  other than that its all server-side work as
the data in the session is stored either in a database or in a file on
the server. SessionID may also be passed via get request and can get by
without a cookie to store the id.

This is the reason why Sessions are more popular now then using cookies,
you can getaway with not even having cookies enabled.

regards trookat.

Re: How send $_SESSION vars to the server

Bill H wrote:
Quoted text here. Click to load it

Javascript runs on the client and cannot call a PHP script, which runs
on the server.

All javascript can do is make AJAX calls - which effectively loads a new
page from the server's viewpoint.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline