I have a session in my main window. Freom here, I want to open a
popup, load a page and access the $_SESSION[] array but I seem not
able to in my pop up.
<?php
session_start();
var_dump($_SESSION);
?>
at the top of my popup script just prints
array(0) { }
and this is what the session dumps on the page from where I open the
popup:
string(2) "10"
Why is that? What's going on here, I seems to recall that i used this
before and it worked just fine - any clues?
> I have a session in my main window. Freom here, I want to open a
> popup, load a page and access the $_SESSION[] array but I seem not
> able to in my pop up.
> <?php
> session_start();
> var_dump($_SESSION);
> ?>
> at the top of my popup script just prints
> array(0) { }
> and this is what the session dumps on the page from where I open the
> popup:
> string(2) "10"
> Why is that? What's going on here, I seems to recall that i used this
> before and it worked just fine - any clues?
> Thank you!
> Ron
Are you outputting ANYTHING - including whitespace - before the call to session_start()?
Is the popup accessing the same domain as the main window?
-- ==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
> > I have a session in my main window. Freom here, I want to open a
> > popup, load a page and access the $_SESSION[] array but I seem not
> > able to in my pop up.
> > <?php
> > session_start();
> > var_dump($_SESSION);
> > ?>
> > at the top of my popup script just prints
> > array(0) { }
> > and this is what the session dumps on the page from where I open the
> > popup:
> > string(2) "10"
> > Why is that? What's going on here, I seems to recall that i used this
> > before and it worked just fine - any clues?
> > Thank you!
> > Ron
> Are you outputting ANYTHING - including whitespace - before the call to
> session_start()?
No,
In both files, the first characters are:
<?php
session_start();
> Is the popup accessing the same domain as the main window?
Yes, they're both on the same domain, different directories tho but
that shouldn't matter, would it?
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================
> On Feb 13, 11:30 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> > On 2/13/2012 2:21 PM, cerr wrote:
> > > Hi There,
> > > I have a session in my main window. Freom here, I want to open a
> > > popup, load a page and access the $_SESSION[] array but I seem not
> > > able to in my pop up.
> > > <?php
> > > session_start();
> > > var_dump($_SESSION);
> > > ?>
> > > at the top of my popup script just prints
> > > array(0) { }
> > > and this is what the session dumps on the page from where I open the
> > > popup:
> > > string(2) "10"
<?php
session_start();
echo session_id();
Now I tried passing the session id along as a get variable and in my
pop up script it now says
<?php
session_start();
echo $_GET['sessionid']."<br/>";
session_id($_GET['sessionid']);
echo session_id();
?>
On top. I confirm that the session id gets set to the correct value
but I still can't retrieve my UserID value from the session variable.
Something seems to be majorly messed up... :(
cerr wrote:
> On Feb 13, 11:30 am, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 2/13/2012 2:21 PM, cerr wrote:
>>> <?php
>>> session_start();
>>> var_dump($_SESSION);
>>> ?>
>>> at the top of my popup script just prints
>>> array(0) { }
>>> and this is what the session dumps on the page from where I open the
>>> popup:
>>> string(2) "10"
If you have used
$_SESSION = "10";
then you haven't used the session as it's intended to work, try instead:
$_SESSION['integer'] = 10;
>> Is the popup accessing the same domain as the main window?
> Yes, they're both on the same domain, different directories tho but
> that shouldn't matter, would it?
> cerr wrote:
> > On Feb 13, 11:30 am, Jerry Stuckle<jstuck...@attglobal.net> wrote:
> >> On 2/13/2012 2:21 PM, cerr wrote:
> >>> <?php
> >>> session_start();
> >>> var_dump($_SESSION);
> >>> ?>
> >>> at the top of my popup script just prints
> >>> array(0) { }
> >>> and this is what the session dumps on the page from where I open the
> >>> popup:
> >>> string(2) "10"
> If you have used
> $_SESSION = "10";
I didn't.
> then you haven't used the session as it's intended to work, try instead:
> $_SESSION['integer'] = 10;
I do use it like an array: $_SESSION['userid']
> >> Is the popup accessing the same domain as the main window?
> > Yes, they're both on the same domain, different directories tho but
> > that shouldn't matter, would it?
I'm currently not using cookies, I'm passing the sessionid as a get
variable to the script and set it like:
session_id($_GET['sessionid']);
session_start();
echo $_GET['sessionid']."<br/>";
echo session_id();
> OT: Please remove things that you don't reply at, like signatures.
>I'm currently not using cookies, I'm passing the sessionid as a get
>variable to the script and set it like:
Then most likely the SID gets lost when you open your pop-up. In cases
like this you would have to manually append the predefined constant
'SID' to your URL. See the manual for details. [1]
But the better and recommended way would be to use a session cookie -
that's what cookies are for. SIDs in URLs are a security risk, because
they're stored in logfiles and in HTTP Referrer headers, which exposes
the SID to other people and might allow session hijacking. [2]
So better use a cookie instead, which is safer and should also solve
your problem. Also change these configuration options:
> >I'm currently not using cookies, I'm passing the sessionid as a get
> >variable to the script and set it like:
> Then most likely the SID gets lost when you open your pop-up. In cases
> like this you would have to manually append the predefined constant
> 'SID' to your URL. See the manual for details. [1]
> But the better and recommended way would be to use a session cookie -
> that's what cookies are for. SIDs in URLs are a security risk, because
> they're stored in logfiles and in HTTP Referrer headers, which exposes
> the SID to other people and might allow session hijacking. [2]
> So better use a cookie instead, which is safer and should also solve
> your problem. Also change these configuration options:
So Thanks for everyone's feedback. I suddenly started to work as
expected which is very confusing to me and to me... I can not tell
what made this happen... I went as far as rebooting Windows, trying
different browsers and and and.... and then it suddenly... just
worked... :o Very strange and kinda scary!
Thanks for everyone's feedback anyways, it is much appreciated!
> I have a session in my main window. Freom here, I want to open a
> popup, load a page and access the $_SESSION[] array but I seem not
> able to in my pop up.
> <?php
> session_start();
> var_dump($_SESSION);
> ?>
> at the top of my popup script just prints
> array(0) { }
> and this is what the session dumps on the page from where I open the
> popup:
> string(2) "10"
> Why is that? What's going on here, I seems to recall that i used this
> before and it worked just fine - any clues?
$_SESSION is an array, not a string, so the funny thing is that it's only working as expected in the popup window :)