Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #4801 > unrolled thread
| Started by | cerr <ron.eggler@gmail.com> |
|---|---|
| First post | 2012-02-13 11:21 -0800 |
| Last post | 2012-02-15 18:34 +0100 |
| Articles | 13 — 6 participants |
Back to article view | Back to comp.lang.php
session array not available in popup? cerr <ron.eggler@gmail.com> - 2012-02-13 11:21 -0800
Re: session array not available in popup? Jerry Stuckle <jstucklex@attglobal.net> - 2012-02-13 14:30 -0500
Re: session array not available in popup? cerr <ron.eggler@gmail.com> - 2012-02-13 11:37 -0800
Re: session array not available in popup? cerr <ron.eggler@gmail.com> - 2012-02-13 12:04 -0800
Re: session array not available in popup? "J.O. Aho" <user@example.net> - 2012-02-13 21:12 +0100
Re: session array not available in popup? cerr <ron.eggler@gmail.com> - 2012-02-13 12:53 -0800
Re: session array not available in popup? The Natural Philosopher <tnp@invalid.invalid> - 2012-02-13 22:15 +0000
Re: session array not available in popup? Michael Fesser <netizen@gmx.de> - 2012-02-14 00:45 +0100
Re: session array not available in popup? The Natural Philosopher <tnp@invalid.invalid> - 2012-02-14 11:59 +0000
Re: session array not available in popup? cerr <ron.eggler@gmail.com> - 2012-02-14 10:30 -0800
Re: session array not available in popup? Michael Fesser <netizen@gmx.de> - 2012-02-14 00:59 +0100
Re: session array not available in popup? cerr <ron.eggler@gmail.com> - 2012-02-14 10:33 -0800
Re: session array not available in popup? "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-02-15 18:34 +0100
| From | cerr <ron.eggler@gmail.com> |
|---|---|
| Date | 2012-02-13 11:21 -0800 |
| Subject | session array not available in popup? |
| Message-ID | <68e1d7a7-3a12-4cb4-b43e-b96f3d5a14ca@qt7g2000pbc.googlegroups.com> |
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"
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
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-02-13 14:30 -0500 |
| Message-ID | <jhbodh$h6d$1@dont-email.me> |
| In reply to | #4801 |
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"
>
> 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.
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | cerr <ron.eggler@gmail.com> |
|---|---|
| Date | 2012-02-13 11:37 -0800 |
| Message-ID | <4b3bba57-105b-4618-8be7-3fd8e15e5c47@m3g2000pbi.googlegroups.com> |
| In reply to | #4802 |
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"
>
> > 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
> ==================
[toc] | [prev] | [next] | [standalone]
| From | cerr <ron.eggler@gmail.com> |
|---|---|
| Date | 2012-02-13 12:04 -0800 |
| Message-ID | <fd88dc2e-0e39-46c5-bc19-d4ba9645d956@ir9g2000pbc.googlegroups.com> |
| In reply to | #4803 |
On Feb 13, 11:37 am, cerr <ron.egg...@gmail.com> wrote:
> 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... :(
[toc] | [prev] | [next] | [standalone]
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Date | 2012-02-13 21:12 +0100 |
| Message-ID | <9pt94sFuf8U1@mid.individual.net> |
| In reply to | #4803 |
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?
Depends on your session.cookie_path
See: http://www.php.net/manual/en/function.session-set-cookie-params.php
http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-path
OT: Please remove things that you don't reply at, like signatures.
--
//Aho
[toc] | [prev] | [next] | [standalone]
| From | cerr <ron.eggler@gmail.com> |
|---|---|
| Date | 2012-02-13 12:53 -0800 |
| Message-ID | <cdf92aae-40ca-4d64-8f8d-87f5f6a4a008@vv9g2000pbc.googlegroups.com> |
| In reply to | #4805 |
On Feb 13, 12:12 pm, "J.O. Aho" <u...@example.net> wrote:
> 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?
>
> Depends on your session.cookie_path
>
> See:http://www.php.net/manual/en/function.session-set-cookie-params.phphttp://www.php.net/manual/en/session.configuration.php#ini.session.co...
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.
Yep, sorry
[toc] | [prev] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2012-02-13 22:15 +0000 |
| Message-ID | <jhc21f$qou$2@news.albasani.net> |
| In reply to | #4806 |
cerr wrote: > I'm currently not using cookies, If you are using sessions, you are using cookies. How else do you think they worked?
[toc] | [prev] | [next] | [standalone]
| From | Michael Fesser <netizen@gmx.de> |
|---|---|
| Date | 2012-02-14 00:45 +0100 |
| Message-ID | <f28jj7ddknfsmdg7ekoj0fe430r6aprden@mfesser.de> |
| In reply to | #4807 |
.oO(The Natural Philosopher) >cerr wrote: > >> I'm currently not using cookies, > >If you are using sessions, you are using cookies. Not necessarily. >How else do you think they worked? Read what he wrote: SID in URL. Yes, it works, but is not recommended. Micha -- http://mfesser.de/blickwinkel
[toc] | [prev] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2012-02-14 11:59 +0000 |
| Message-ID | <jhdiab$837$7@news.albasani.net> |
| In reply to | #4808 |
Michael Fesser wrote: > .oO(The Natural Philosopher) > >> cerr wrote: >> >>> I'm currently not using cookies, >> If you are using sessions, you are using cookies. > > Not necessarily. > >> How else do you think they worked? > > Read what he wrote: SID in URL. Yes, it works, but is not recommended. > Ghastliness personified. > Micha >
[toc] | [prev] | [next] | [standalone]
| From | cerr <ron.eggler@gmail.com> |
|---|---|
| Date | 2012-02-14 10:30 -0800 |
| Message-ID | <fc02cbae-2dde-4180-bee7-64f7ee739c81@qt10g2000pbb.googlegroups.com> |
| In reply to | #4810 |
On Feb 14, 3:59 am, The Natural Philosopher <t...@invalid.invalid> wrote: > Michael Fesser wrote: > > .oO(The Natural Philosopher) > > >> cerr wrote: > > >>> I'm currently not using cookies, > >> If you are using sessions, you are using cookies. > > > Not necessarily. > > >> How else do you think they worked? > > > Read what he wrote: SID in URL. Yes, it works, but is not recommended. > > Ghastliness personified. Yep, I read up on it, I'm using them with cookies.
[toc] | [prev] | [next] | [standalone]
| From | Michael Fesser <netizen@gmx.de> |
|---|---|
| Date | 2012-02-14 00:59 +0100 |
| Message-ID | <a48jj7tk3g0cv5ubd8gpdbjpv8bhavmji2@mfesser.de> |
| In reply to | #4806 |
.oO(cerr) >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: session.use_trans_sid = 0 session.use_only_cookies = 1 to prevent PHP from automatically rewriting URLs. Micha [1] http://www.php.net/manual/en/session.idpassing.php [2] http://www.php.net/manual/en/session.security.php -- http://mfesser.de/blickwinkel
[toc] | [prev] | [next] | [standalone]
| From | cerr <ron.eggler@gmail.com> |
|---|---|
| Date | 2012-02-14 10:33 -0800 |
| Message-ID | <8c80f799-2255-46a3-a848-d780c7fe8b08@n8g2000pbc.googlegroups.com> |
| In reply to | #4809 |
On Feb 13, 3:59 pm, Michael Fesser <neti...@gmx.de> wrote: > .oO(cerr) > > >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: > > session.use_trans_sid = 0 > session.use_only_cookies = 1 > > to prevent PHP from automatically rewriting URLs. > > Micha > > [1]http://www.php.net/manual/en/session.idpassing.php > [2]http://www.php.net/manual/en/session.security.php > > --http://mfesser.de/blickwinkel 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! Ron
[toc] | [prev] | [next] | [standalone]
| From | "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> |
|---|---|
| Date | 2012-02-15 18:34 +0100 |
| Message-ID | <jhgqal$tpo$1@dont-email.me> |
| In reply to | #4801 |
El 13/02/2012 20:21, cerr escribió/wrote:
> 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 :)
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web