New to Sessions 2

New to Sessions 2

am 23.11.2007 08:40:32 von jodleren

Hi!

I started a thread app 2 weeks ago and redlied to that, but it seems
to be so low in the list, that it will not be seen.

My problem - I need to transfer the sesstion to another page?

say page1.php goes to page2.php ( ) ?

So, s start_sesstion, $_SESSION["fgdf"]=fsdgdf should be readable by
the other file... how do I achive that?

WBR
Sonnich

Re: New to Sessions 2

am 23.11.2007 09:24:25 von Erwin Moller

jodleren wrote:
> Hi!
>
> I started a thread app 2 weeks ago and redlied to that, but it seems
> to be so low in the list, that it will not be seen.
>
> My problem - I need to transfer the sesstion to another page?
>
> say page1.php goes to page2.php (
) ?
>
> So, s start_sesstion, $_SESSION["fgdf"]=fsdgdf should be readable by
> the other file... how do I achive that?
>
> WBR
> Sonnich

Add to both pages:
session_start();

Do this before you do anything else, like creating output.
so on page1.php:

session_start();
$_SESSION["test"] = "Hi";


and on page2.php
session_start();
echo $_SESSION["test"];
// should say Hi


Regards,
Erwin Moller

PS: Make sure you have error reporting ON.
PS2: Make sure your php.ini doesn't have session_auto_start on.

Re: New to Sessions 2

am 23.11.2007 10:24:34 von Toby A Inkster

jodleren wrote:

> My problem - I need to transfer the sesstion to another page?
> say page1.php goes to page2.php (
) ?

That's how sessions work. Data is shared between pages by default. That's
the whole point of them.

Simply call start_session() at the top of both pages, and they can share
data. (A lot of newbies think that start_session() creates a new blank
session, wiping out any old session data. It does not. Think of it as
meaning "start using the session", not "start a new session".)

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 14:20.]

It'll be in the Last Place You Look
http://tobyinkster.co.uk/blog/2007/11/21/no2id/

Re: New to Sessions 2

am 23.11.2007 12:02:52 von jodleren

On Nov 23, 10:24 am, Erwin Moller
wrote:
> jodleren wrote:
> > Hi!
>
> > I started a thread app 2 weeks ago and redlied to that, but it seems
> > to be so low in the list, that it will not be seen.
>
> > My problem - I need to transfer the sesstion to another page?
>
> > say page1.php goes to page2.php (
) ?
>
> > So, s start_sesstion, $_SESSION["fgdf"]=fsdgdf should be readable by
> > the other file... how do I achive that?
>
> > WBR
> > Sonnich
>
> Add to both pages:
> session_start();
>
> Do this before you do anything else, like creating output.
> so on page1.php:
>
> session_start();
> $_SESSION["test"] = "Hi";
>
> and on page2.php
> session_start();
> echo $_SESSION["test"];
> // should say Hi
>
> Regards,
> Erwin Moller
>
> PS: Make sure you have error reporting ON.
> PS2: Make sure your php.ini doesn't have session_auto_start on.

Thanks, I got it to work. Toby's explanation cleared things up.

Erwin, ma vist tunnen sind. Kas sa oleks nii hea, saata mulle maili,
aadress peaks siin sama olema.

Re: New to Sessions 2

am 23.11.2007 12:40:43 von Erwin Moller

jodleren wrote:
> On Nov 23, 10:24 am, Erwin Moller
> wrote:
>> jodleren wrote:
>>> Hi!
>>> I started a thread app 2 weeks ago and redlied to that, but it seems
>>> to be so low in the list, that it will not be seen.
>>> My problem - I need to transfer the sesstion to another page?
>>> say page1.php goes to page2.php (
) ?
>>> So, s start_sesstion, $_SESSION["fgdf"]=fsdgdf should be readable by
>>> the other file... how do I achive that?
>>> WBR
>>> Sonnich
>> Add to both pages:
>> session_start();
>>
>> Do this before you do anything else, like creating output.
>> so on page1.php:
>>
>> session_start();
>> $_SESSION["test"] = "Hi";
>>
>> and on page2.php
>> session_start();
>> echo $_SESSION["test"];
>> // should say Hi
>>
>> Regards,
>> Erwin Moller
>>
>> PS: Make sure you have error reporting ON.
>> PS2: Make sure your php.ini doesn't have session_auto_start on.
>
> Thanks, I got it to work. Toby's explanation cleared things up.

Cool. :-)

>
> Erwin, ma vist tunnen sind. Kas sa oleks nii hea, saata mulle maili,
> aadress peaks siin sama olema.

Erm....
I am from Holland/The Netherlands, not Sweden.
Or is it norwegian? Danish? Finnish?
Sounds all impossible to me. ;-)

Regards,
Erwin Moller

Re: New to Sessions 2

am 23.11.2007 13:04:44 von jodleren

On Nov 23, 1:40 pm, Erwin Moller
wrote:
> jodleren wrote:
> > On Nov 23, 10:24 am, Erwin Moller
> > wrote:
> >> jodleren wrote:

> > Thanks, I got it to work. Toby's explanation cleared things up.
>
> Cool. :-)
>
> > Erwin, ma vist tunnen sind. Kas sa oleks nii hea, saata mulle maili,
> > aadress peaks siin sama olema.
>
> Erm....
> I am from Holland/The Netherlands, not Sweden.
> Or is it norwegian? Danish? Finnish?
> Sounds all impossible to me. ;-)

Estonian. I once had contact to him around here, he works with that
kind of stuff too... :-)

Grootjes
Sonnich