List Info

Thread: Re: Jquery, AJAX, and php session variables




Re: Jquery, AJAX, and php session variables
country flaguser name
United States
2007-03-30 11:58:40
I am indeed not using output buffering. I call
session_start as the first thing on every page, before
the headers are sent. I also call session_start on my
login page, first thing. 

If I use output buffering, do you think that would fix
things? I could call session_start() again as a
callback function after the ajax finishes, perhaps...?

thanks,
-kim

--- Aaron Heimlich <aaron.heimlichgmail.com> wrote:

> On 3/30/07, Kim Johnson <egypt1anyahoo.com> wrote:
> >
> > Should I be recalling
> > session_start?
> 
> 
> As a general rule, you should call session_start()
> in *every* PHP script
> that accesses $_SESSION. Where you call it depends
> on whether you're using
> output buffering or not[1], but it must *always* be
> *before* you access
> $_SESSION for the first time in that script.
> 
> 
> [1] If you're not using output buffering (
> http:/
/us.php.net/manual/en/ref.outcontrol.php),
> then you *must* call
> session_start() *before* any output is sent to the
> browser, otherwise you'll
> get a "can't send headers because headers were
> already sent" error (this
> means that the call to session_start() should
> probably be the very first
> thing your script does). If you are using output
> buffering, then you can
> call it pretty much anywhere in your script before
> you send the contents of
> the output buffer to the browser.
> 
> -- 
> Aaron Heimlich
> Web Developer
> aaron.heimlichgmail.com
> http://aheimlich.freepgs
.com
> > _______________________________________________
> jQuery mailing list
> discussjquery.com
> http://jquery.com/discuss/

> 



 
____________________________________________________________
________________________
No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/
mail 

_______________________________________________
jQuery mailing list
discussjquery.com
http://jquery.com/discuss/


Re: Jquery, AJAX, and php session variables
user name
2007-03-30 12:07:53
Question: is session_start() called on the page where this code is run?

var loggedin = <?=$_SESSION['loggedin9;]?>;

if (loggedin == true)
{
                                       $(&quot;div#login").hide();          $(&quot;div#logout").unhide();
}
else
{
       $(&quot;div#login").unhide();
       $(&quot;div#logout").hide();
}

On 3/30/07, Kim Johnson < egypt1anyahoo.com"> egypt1anyahoo.com> wrote:
I am indeed not using output buffering. I call
session_start as the first thing on every page, before
the headers are sent. I also call session_start on my
login page, first thing.

If I use output buffering, do you think that would fix
things? I could call session_start() again as a
callback function after the ajax finishes, perhaps...?

thanks,
-kim

--- Aaron Heimlich < aaron.heimlichgmail.com">aaron.heimlichgmail.com> wrote:

&gt; On 3/30/07, Kim Johnson < egypt1anyahoo.com">egypt1anyahoo.com > wrote:
>; >
> > Should I be recalling
> > session_start?
>
&gt;
> As a general rule, you should call session_start()
> in *every* PHP script
>; that accesses $_SESSION. Where you call it depends
> on whether you're using
> output buffering or not[1], but it must *always* be
> *before* you access
>; $_SESSION for the first time in that script.
&gt;
>
>; [1] If you're not using output buffering (
> http://us.php.net/manual/en/ref.outcontrol.php),
> then you *must* call
> session_start() *before* any output is sent to the
> browser, otherwise you'll
> get a "can&#39;t send headers because headers were
> already sent" error (this
> means that the call to session_start() should
>; probably be the very first
> thing your script does). If you are using output
&gt; buffering, then you can
> call it pretty much anywhere in your script before
>; you send the contents of
> the output buffer to the browser.
&gt;
> --
> Aaron Heimlich
&gt; Web Developer
> aaron.heimlichgmail.com">aaron.heimlichgmail.com
> http://aheimlich.freepgs.com
&gt; > _______________________________________________
> jQuery mailing list
> discussjquery.com">discussjquery.com
> http://jquery.com/discuss/
>




____________________________________________________________________________________
No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail

_______________________________________________
jQuery mailing list
discussjquery.com">discussjquery.com
http://jquery.com/discuss/



--
Aaron Heimlich
Web Developer
aaron.heimlichgmail.com">aaron.heimlichgmail.com
http://aheimlich.freepgs.com
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )