Reply to Re: Can't read $_SESSION variables set by previous request, AJAX

Your name:

Reply:


Posted by Evil Otto on 02/19/07 18:10

On Feb 19, 7:24 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Evil Otto wrote:
> > session_start() is called exactly once, at the beginning of the main
> > script.
>
> > There are multiple requests, but there is ONE page.
>
> > I've tried putting session_start() at the beginning of the functions
> > that get called, but they throw "session has already been started"
> > errors.
>
> > On Feb 18, 9:40 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> >> Evil Otto wrote:
> >>> The only error i get is an undefined index message when the third
> >>> request tries to access the $_SESSION variable.
> >>> On Feb 18, 8:37 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> >>>> Evil Otto wrote:
> >>>>> I removed the ?> and <?php tags from where you saw the whitespace, so
> >>>>> there's no extraneous whitespace. Had no effect on the problem I'm
> >>>>> seeing; the third request still cannot see changes to the $_SESSION
> >>>>> variable made by the second.
> >>>>> On Feb 18, 3:24 pm, Kimmo Laine <s...@outolempi.net> wrote:
> >>>>>> Evil Otto kirjoitti:
> >>>>>>> There's no output going to the browser before session_start(). The
> >>>>>>> top of my script looks like this:
> >>>>>>> --quote
> >>>>>>> <?php
> >>>>>>> error_reporting(E_ALL);
> >>>>>>> ini_set("display_errors","1");
> >>>>>>> ?>
> >>>>>> Output starts here cos you have a gap between two php tags. It's the
> >>>>>> whitespace effect.
> >>>>>>> <?php
> >>>>>> --
> >>>>>> "En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
> >>>>>> s...@outolempi.net | Gedoon-S @ IRCnet | rot13(x...@bhgbyrzcv.arg)
> >>>> And can you be sure that *NOTHING* in your include.php file generates
> >>>> output - including leading or trailing blanks, newline characters, etc.?
> >>>> What do you get for error messages?
> >>>> --
> >>>> ==================
> >>>> Remove the "x" from my email address
> >>>> Jerry Stuckle
> >>>> JDS Computer Training Corp.
> >>>> jstuck...@attglobal.net
> >>>> ==================
> >> In that case there are only two options. Either the second page didn't
> >> call session_start() before any output, or the third page didn't do it.
>
> >> Sessions work. If the second page properly starts the session and sets
> >> the session info, and the third page properly starts the session, it
> >> does work.
>
> >> I know this sounds blunt - and I'm really sorry, I don't mean to be
> >> blunt about it. But sessions do work. If you have a case where the
> >> second page sets a session variable and the third page can't read it,
> >> one of two things is wrong:
>
> >> 1. The second page didn't actually set the $_SESSION value in the
> >> session (possibly because session_start wasn't called early enough - but
> >> there could be other reasons), or
> >> 2. The third page can't read the $_SESSION value. In this case if it
> >> is set, about the only option you have is that session_start() wasn't
> >> called soon enough.
>
> >> So, if the third page (where the value is read) is correct, perhaps the
> >> second page (where it is set) has a problem?
>
> >> It's got to be one or the other.
>
> >> --
> >> ==================
> >> Remove the "x" from my email address
> >> Jerry Stuckle
> >> JDS Computer Training Corp.
> >> jstuck...@attglobal.net
> >> ==================
>
> Hmmm, when you say
>
> "The content it returns includes a link that calls the same variable,
> but I get an error that says the index isn't defined."
>
> what do you mean exactly? Is this an html link? A function call?
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

This is an onClick attribute in a div that calls a javascript
function, which makes an Ajax request calling a PHP funciton on the
server.

I think i may have cleared this up, however. Turns out a
session_destroy() was in the wrong place, and an undefined index
should have been expected.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация