pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
session_is_started()
5+ messages / 3 participants
[nested] [flat]

* session_is_started()
@ 2004-04-08 13:40 Joolz <joolz@xs4all.nl>
  2004-04-08 14:49 ` Re: session_is_started() Wim Paulussen <wim@chen.be>
  2004-04-09 05:35 ` Re: session_is_started() Tin <canobi@email.hinet.hr>
  0 siblings, 2 replies; 5+ messages in thread

From: Joolz @ 2004-04-08 13:40 UTC (permalink / raw)
  To: pgsql-php

Hello,

I'm makeing a PHP frontend to a postgresql db, and want to use
sessions in order to sore global variables. I read that it's enough to
put session_start() in the top file of the app, but that doesn't work,
when I go two or three PHP files "deep", the session is forgotten.

To workaround this, I tried putting session_start() at the begonning
of every PHP file that does something with session variables. This
however gives me lot of these errors: "Notice: A session had already
been started - ignoring session_start() in [scriptname] on line 5"

I would like something like

if (!session_is_started()) { // note: this function doesn't exist
  session_start();
}

How have you solved this problem? Thanks for any tips!

-- 
15:36-15:40
Fedora Core release 1 (Yarrow) Linux 2.4.22-1.2174.nptl



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: session_is_started()
  2004-04-08 13:40 session_is_started() Joolz <joolz@xs4all.nl>
@ 2004-04-08 14:49 ` Wim Paulussen <wim@chen.be>
  2004-04-09 13:47   ` Re: session_is_started() Joolz <joolz@xs4all.nl>
  1 sibling, 1 reply; 5+ messages in thread

From: Wim Paulussen @ 2004-04-08 14:49 UTC (permalink / raw)
  To: pgsql-php

I would do the following : on the first page you start the session with 
session_start and then you include an OK field in the session
<code>
($_SESSION['OK']   = TRUE;
</code>
On the following pages , the first thing you do is check the existence 
of the variable like this
<code>
if (! isset($_SESSION['OK']))
{
    session_start();
}
</code>

Your problems derives most probably from teh fact that in your php.ini 
the session.autostart is set to On , starting a session automatically 
once 1 time started.


Joolz wrote:

>Hello,
>
>I'm makeing a PHP frontend to a postgresql db, and want to use
>sessions in order to sore global variables. I read that it's enough to
>put session_start() in the top file of the app, but that doesn't work,
>when I go two or three PHP files "deep", the session is forgotten.
>
>To workaround this, I tried putting session_start() at the begonning
>of every PHP file that does something with session variables. This
>however gives me lot of these errors: "Notice: A session had already
>been started - ignoring session_start() in [scriptname] on line 5"
>
>I would like something like
>
>if (!session_is_started()) { // note: this function doesn't exist
>  session_start();
>}
>
>How have you solved this problem? Thanks for any tips!
>
>  
>




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: session_is_started()
  2004-04-08 13:40 session_is_started() Joolz <joolz@xs4all.nl>
  2004-04-08 14:49 ` Re: session_is_started() Wim Paulussen <wim@chen.be>
@ 2004-04-09 13:47   ` Joolz <joolz@xs4all.nl>
  0 siblings, 0 replies; 5+ messages in thread

From: Joolz @ 2004-04-09 13:47 UTC (permalink / raw)
  To: pgsql-php

> [Wim Paulussen schreef op 08-04-2004 16:49 +0200]

Hallo Wim, bedankt voor je reactie! (just saying hello to Wim)

> I would do the following : on the first page you start the session with 
> session_start and then you include an OK field in the session
> <code>
> ($_SESSION['OK']   = TRUE;
> </code>
> On the following pages , the first thing you do is check the existence 
> of the variable like this
> <code>
> if (! isset($_SESSION['OK']))
> {
>    session_start();
> }
> </code>

I tried this:

  if (!isset($_SESSION['id'])) {
    // id is a session variable that contains the user id
    session_start();
  }

The output is:

  Notice: A session had already been started - ignoring session_start()
  in [scriptname] on line 3

I can't figure out what's going wrong...

> Your problems derives most probably from teh fact that in your php.ini 
> the session.autostart is set to On , starting a session automatically 
> once 1 time started.

No... It was on, but setting it off doesn't change the behaviour :-(

> Joolz wrote:
> 
> >Hello,
> >
> >I'm makeing a PHP frontend to a postgresql db, and want to use
> >sessions in order to sore global variables. I read that it's enough to
> >put session_start() in the top file of the app, but that doesn't work,
> >when I go two or three PHP files "deep", the session is forgotten.
> >
> >To workaround this, I tried putting session_start() at the begonning
> >of every PHP file that does something with session variables. This
> >however gives me lot of these errors: "Notice: A session had already
> >been started - ignoring session_start() in [scriptname] on line 5"
> >
> >I would like something like
> >
> >if (!session_is_started()) { // note: this function doesn't exist
> > session_start();
> >}
> >
> >How have you solved this problem? Thanks for any tips!
> >
> > 
> >
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
> 

-- 
15:42-15:47
Fedora Core release 1 (Yarrow) Linux 2.4.22-1.2174.nptl



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: session_is_started()
  2004-04-08 13:40 session_is_started() Joolz <joolz@xs4all.nl>
@ 2004-04-09 05:35 ` Tin <canobi@email.hinet.hr>
  2004-04-13 09:43   ` Re: session_is_started() Joolz <joolz@xs4all.nl>
  1 sibling, 1 reply; 5+ messages in thread

From: Tin @ 2004-04-09 05:35 UTC (permalink / raw)
  To: pgsql-php

Joolz wrote:
> I would like something like
> 
> if (!session_is_started()) { // note: this function doesn't
> exist
>   session_start();
> }

  Hi,

  this is not really a postgres-related question, but what the
heck. Use session_id to detect if a session is started or not.
See: http://hr2.php.net/manual/en/function.session-id.php for an
example (user-contributed, at the bottom of the page).




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: session_is_started()
  2004-04-08 13:40 session_is_started() Joolz <joolz@xs4all.nl>
  2004-04-09 05:35 ` Re: session_is_started() Tin <canobi@email.hinet.hr>
@ 2004-04-13 09:43   ` Joolz <joolz@xs4all.nl>
  0 siblings, 0 replies; 5+ messages in thread

From: Joolz @ 2004-04-13 09:43 UTC (permalink / raw)
  To: pgsql-php

> [Tin schreef op 09-04-2004 07:35 +0200]
>
> Joolz wrote:
> > I would like something like
> > 
> > if (!session_is_started()) { // note: this function doesn't
> > exist
> >   session_start();
> > }
> 
>   Hi,
> 
>   this is not really a postgres-related question, but what the
> heck. Use session_id to detect if a session is started or not.
> See: http://hr2.php.net/manual/en/function.session-id.php for an
> example (user-contributed, at the bottom of the page).

Great, thanks!


-- 
11:42-11:42
Fedora Core release 1 (Yarrow) Linux 2.4.22-1.2174.nptl



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2004-04-13 09:43 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-04-08 13:40 session_is_started() Joolz <joolz@xs4all.nl>
2004-04-08 14:49 ` Wim Paulussen <wim@chen.be>
2004-04-09 13:47   ` Joolz <joolz@xs4all.nl>
2004-04-09 05:35 ` Tin <canobi@email.hinet.hr>
2004-04-13 09:43   ` Joolz <joolz@xs4all.nl>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox