|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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. Let's also assume I am not assigning Global variables within any of the code. But, if by chance one of those 'other' pages ALSO begins with a session_start(); does that close the first session and throw away its variables, making them no longer available from 'other' pages? Is the above what the line $_SESSION['views']=n; is intended to accomodate? e.g.: <?php session_start(); // store session data $_SESSION['views']=1; ?> <html> <body> 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? I'm trying to work it our programatically but it's a little confusing without some verification from the 'ones that know' if you will. TIA Twane |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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'? -- Rik Wasmus ....spamrun finished |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
using session_start() on a script - if there is no session it sets
one up; if there is a session, it opens it. If you wait too long between pages it disposes the session automatically (set time for session to keep alive in php.ini). You need session_start() on all pages that needs to access the $_SESSION array. $_SESSION is just like an array variable, so if you want to segregate data you could set a sub array of page data in $_SESSION... $_SESSION['views'][1] = ...array of data...; Hope that s Larry |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
> 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 |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
> using session_start() on a script - if there is no session it sets
> one up; if there is a session, it opens it. If you wait too long > between pages it disposes the session automatically (set time for > session to keep alive in php.ini). Ha! I think that might explain a couple of "strange" events that happen when I go away and come back later! If I read that right, it's only about 24 minutes (1440 S). I'm not going to change it because I don't know the nuances/inter-plays of the php.ini yet. I'm perfectly happy just knowing there's a reason for it! I've been getting ready to blame the OS. > > You need session_start() on all pages that needs to access the > $_SESSION array. > > $_SESSION is just like an array variable, so if you want to segregate > data you could set a sub array of page data in $_SESSION... > > $_SESSION['views'][1] = ...array of data...; > > Hope that s > Larry I think I'm starting to catch on; for whatever reason I've been totally misinterpreting some of these things including $_SESSION. It's always hardest for me to get the basics into my head when I start something new like this. Thanks much Twayne |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
Twayne schrieb:
> 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. Let's also > assume I am not assigning Global variables within any of the code. > > But, if by chance one of those 'other' pages ALSO begins with a > session_start(); does that close the first session and throw away its > variables, making them no longer available from 'other' pages? > Is the above what the line $_SESSION['views']=n; is intended to > accomodate? > e.g.: > > <?php > session_start(); > // store session data > $_SESSION['views']=1; > ?> > <html> > <body> > > 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? > > I'm trying to work it our programatically but it's a little confusing > without some verification from the 'ones that know' if you will. > > TIA > > Twane > > WHY dont´t you read the PHP Manual? Everything is described. Sessions too. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Jun 14, 11:02 am, "Twayne" <nob...@devnull.spamcop.net> wrote:
> > > You need session_start() on all pages that needs to access the > > $_SESSION array. > > > $_SESSION is just like an array variable, so if you want to segregate > > data you could set a sub array of page data in $_SESSION... > > > $_SESSION['views'][1] = ...array of data...; > > > I think I'm starting to catch on; for whatever reason I've been totally > misinterpreting some of these things including $_SESSION. It's always > hardest for me to get the basics into my head when I start something new > like this. Sometimes it's a lot more simpler then you realize. How to use arrays is a big part of making some cool PHP stuff, especially how to handle them in form data and in $_SESSION. It's taken me a while to wrap my brain around it too, but its worth it. |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
> Twayne schrieb:
>> 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. Let's >> also assume I am not assigning Global variables within any of >> the code. But, if by chance one of those 'other' pages ALSO begins >> with a >> session_start(); does that close the first session and throw away its >> variables, making them no longer available from 'other' pages? >> Is the above what the line $_SESSION['views']=n; is intended to >> accomodate? >> e.g.: >> >> <?php >> session_start(); >> // store session data >> $_SESSION['views']=1; >>> >> <html> >> <body> >> >> 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? >> >> I'm trying to work it our programatically but it's a little confusing >> without some verification from the 'ones that know' if you will. >> >> TIA >> >> Twane >> >> > WHY dont´t you read the PHP Manual? > Everything is described. Sessions too. I assume you mean php.net's; not only read it, reread it, reread it, and then reread it again. w3schools is pretty decent stuff. |
|
![]() |
| Outils de la discussion | |
|
|