Afficher un message
Vieux 14/06/2008, 19h34   #4
Twayne
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: very basic: session_start();

> On Sat, 14 Jun 2008 18:56:59 +0200, Twayne
> <nobody@devnull.spamcop.net> wrote:
>
>> If there are better places for basic questions like this, feel free
>> to redirect me.
>>
>> Say I have a php page with session_start(); I can assign variables
>> and those variables will carry over to other pages in order to use
>> them in those other pages, right? e.g. fname and thus $fname.

>
> No, not $fname, $_SESSION['fname'].
>
>> Let's also
>> assume I am not assigning Global variables within any of the code.

>
> Doesn't matter.
>
>> But, if by chance one of those 'other' pages ALSO begins with a
>> session_start();

>
> _every_ page that uses a session has to call session_start() (before
> any output) to be able to use the $_SESSION array.
>
>> does that close the first session and throw away its
>> variables, making them no longer available from 'other' pages?

>
> Nope, it continues the session.
>
>> Is the above what the line $_SESSION['views']=n; is intended to
>> accomodate?

>
>> session_start();
>> $_SESSION['views']=1;

>
> It just sets a variable in the session array.
>
>> Does that then allow me, from any page, to call whichever set of
>> variables I want/need for that particular page by retrieving a
>> 'views' set?

>
> You can only retrieve what you have set in the $_SESSION array. What
> do you mean with a 'views set'?


OK, that s a LOT, Rik!
By "vews set" I meant something totally irrelevant; I thought a "set"
would be, for instance, a 'set' of variables contained in
$_SESSION['views']=1 , then another, different set would be contained in
.... =2, and so on. I kind of caught on some when I came across a PHP
page counter but ... .

%_SESSION is the piece I've been missing out on; don't recall coming
across it before, but that doesn't mean much. I'm still learning to
find my way around the w3schools heriarchies.

Thanks much!

Twayne




  Réponse avec citation
 
Page generated in 0,05392 seconds with 9 queries