sessions?

sessions?

am 17.04.2003 02:42:19 von ODCS

Just trying to understand sessions. For example, I have a user login page
and a logout page. If 10 people are logged in and three of them log out -
how does session_destroy() know which sessions to kill. I understand there
are session id's - but not sure how they are assigned to each user and how
they are controlled. Now what if I wanted to use another session for a
chatroom lets say, same question as above - how are these controlled. I'm
just trying to further understand how exactly sessions work so that when I
am trying to use them I can do so more efficiently.

If someone could explain this aspect of sessions, or point me to a good
write-up, it would be appreciated.

TIA



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: sessions?

am 17.04.2003 03:05:13 von John Holmes

> Just trying to understand sessions. For example, I have a user login
page
> and a logout page. If 10 people are logged in and three of them log
out -
> how does session_destroy() know which sessions to kill. I understand
there
> are session id's - but not sure how they are assigned to each user and
how
> they are controlled. Now what if I wanted to use another session for a
> chatroom lets say, same question as above - how are these controlled.
I'm
> just trying to further understand how exactly sessions work so that
when I
> am trying to use them I can do so more efficiently.

Sessions are controlled by a 32 character session id that is designed to
be unique for each session that's started. When session_start() is
encounted, it looks for a session id in the URL or in a cookie. If it
does not find one, it creates an ID for the request and puts it in
cookie (by default) or in the URL later. If a session ID already exists
when session_start() is called, PHP (by default) opens a file on the
server related to that unique session id and loads the data from it. At
the end of the PHP file, the new/changed session data is saved back to
the file.

If someone logs out and you use session_destroy(), then the file related
to their session ID is destroyed along with the cookie (I think). Now,
if they come back, they'll get a new session ID and a new empty file.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: sessions?

am 17.04.2003 03:05:13 von John Holmes

> Just trying to understand sessions. For example, I have a user login
page
> and a logout page. If 10 people are logged in and three of them log
out -
> how does session_destroy() know which sessions to kill. I understand
there
> are session id's - but not sure how they are assigned to each user and
how
> they are controlled. Now what if I wanted to use another session for a
> chatroom lets say, same question as above - how are these controlled.
I'm
> just trying to further understand how exactly sessions work so that
when I
> am trying to use them I can do so more efficiently.

Sessions are controlled by a 32 character session id that is designed to
be unique for each session that's started. When session_start() is
encounted, it looks for a session id in the URL or in a cookie. If it
does not find one, it creates an ID for the request and puts it in
cookie (by default) or in the URL later. If a session ID already exists
when session_start() is called, PHP (by default) opens a file on the
server related to that unique session id and loads the data from it. At
the end of the PHP file, the new/changed session data is saved back to
the file.

If someone logs out and you use session_destroy(), then the file related
to their session ID is destroyed along with the cookie (I think). Now,
if they come back, they'll get a new session ID and a new empty file.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

session - help

am 17.04.2003 09:15:54 von Saravana Kumar S P

------=_NextPart_000_0033_01C304D2.B65F2D80
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

Am just a beginner to PHP, jumping from ASP. I tried re-coding from my =
small ASP site. And the things worked fine until I met the login page. I =
store the user data in sessions and access then.

The logging name, mail-id, userID are stored in session vars. I used =
this=20

$_SESSION ["MemberName"] =3D "Whatever";
$_SESSION ["MemberId"] =3D "Whatever";
$_SESSION ["MemberMail"] =3D "Whatever";
?>

to store the data on successful login attempt. The page redirects to =
home page after that. When I try to access the session var there... it =
gives a notice saying... the session variable is not defined?? How can I =
avoid that.

I didnt do with session_start () or things like that... as we dont do =
that for in ASP.

Thanks,
SPS

------=_NextPart_000_0033_01C304D2.B65F2D80--

session - help

am 17.04.2003 09:15:54 von Saravana Kumar S P

------=_NextPart_000_0033_01C304D2.B65F2D80
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

Am just a beginner to PHP, jumping from ASP. I tried re-coding from my =
small ASP site. And the things worked fine until I met the login page. I =
store the user data in sessions and access then.

The logging name, mail-id, userID are stored in session vars. I used =
this=20

$_SESSION ["MemberName"] =3D "Whatever";
$_SESSION ["MemberId"] =3D "Whatever";
$_SESSION ["MemberMail"] =3D "Whatever";
?>

to store the data on successful login attempt. The page redirects to =
home page after that. When I try to access the session var there... it =
gives a notice saying... the session variable is not defined?? How can I =
avoid that.

I didnt do with session_start () or things like that... as we dont do =
that for in ASP.

Thanks,
SPS

------=_NextPart_000_0033_01C304D2.B65F2D80--

RE: session - help

am 17.04.2003 09:24:12 von Jill.Ramonsky

Well then there's your problem.
Just add session_start() at the start of any page which uses session
variables (BEFORE reading or writing them).

Jill

PS. Your original post was cross-posted to about three different lists. I
have removed all of them except PHP-WINDOWS from this reply, as I do not
wish my reply to appear on those other lists, of which I am not a member.



-----Original Message-----
From: Saravana Kumar S P [mailto:sps@gulfmd.com]
Sent: Thursday, April 17, 2003 8:16 AM
To: ODCS; PHP General
Cc: PHP Windows
Subject: [PHP-WIN] session - help


Hi,

Am just a beginner to PHP, jumping from ASP. I tried re-coding from my small
ASP site. And the things worked fine until I met the login page. I store the
user data in sessions and access then.

The logging name, mail-id, userID are stored in session vars. I used this

$_SESSION ["MemberName"] = "Whatever";
$_SESSION ["MemberId"] = "Whatever";
$_SESSION ["MemberMail"] = "Whatever";
?>

to store the data on successful login attempt. The page redirects to home
page after that. When I try to access the session var there... it gives a
notice saying... the session variable is not defined?? How can I avoid that.

I didnt do with session_start () or things like that... as we dont do that
for in ASP.

Thanks,
SPS

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: session - help

am 17.04.2003 09:34:24 von Jeremy Weir

You have to call session_start() to initialize a session. Make sure you do
it outside of a function.

read this page: http://www.php.net/manual/en/ref.session.php


"Saravana Kumar S P" wrote in message
news:003801c304b1$3159b130$4bd1a4d9@yaltaserver...
Hi,

Am just a beginner to PHP, jumping from ASP. I tried re-coding from my small
ASP site. And the things worked fine until I met the login page. I store the
user data in sessions and access then.

The logging name, mail-id, userID are stored in session vars. I used this

$_SESSION ["MemberName"] = "Whatever";
$_SESSION ["MemberId"] = "Whatever";
$_SESSION ["MemberMail"] = "Whatever";
?>

to store the data on successful login attempt. The page redirects to home
page after that. When I try to access the session var there... it gives a
notice saying... the session variable is not defined?? How can I avoid that.

I didnt do with session_start () or things like that... as we dont do that
for in ASP.

Thanks,
SPS



--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: session - help

am 17.04.2003 09:34:24 von Jeremy Weir

You have to call session_start() to initialize a session. Make sure you do
it outside of a function.

read this page: http://www.php.net/manual/en/ref.session.php


"Saravana Kumar S P" wrote in message
news:003801c304b1$3159b130$4bd1a4d9@yaltaserver...
Hi,

Am just a beginner to PHP, jumping from ASP. I tried re-coding from my small
ASP site. And the things worked fine until I met the login page. I store the
user data in sessions and access then.

The logging name, mail-id, userID are stored in session vars. I used this

$_SESSION ["MemberName"] = "Whatever";
$_SESSION ["MemberId"] = "Whatever";
$_SESSION ["MemberMail"] = "Whatever";
?>

to store the data on successful login attempt. The page redirects to home
page after that. When I try to access the session var there... it gives a
notice saying... the session variable is not defined?? How can I avoid that.

I didnt do with session_start () or things like that... as we dont do that
for in ASP.

Thanks,
SPS



--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: session - help

am 17.04.2003 09:55:11 von Don Read

On 17-Apr-2003 Saravana Kumar S P wrote:



>
> I didnt do with session_start () or things like that... as we dont do
> that for in ASP.
>

And what happened when we do session_start() (or things like that...) ?

--
Don Read dread@texas.net
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: session - help

am 17.04.2003 10:25:15 von blue_myth_1

> PS. Your original post was cross-posted to about three different
> lists. I
> have removed all of them except PHP-WINDOWS from this reply, as I
> do not
> wish my reply to appear on those other lists, of which I am not a
> member.


:S

cautious jill ????
:|

Y ?????

:)
toby

> -----Original Message-----
> From: Saravana Kumar S P [mailto:sps@gulfmd.com]
> Sent: Thursday, April 17, 2003 8:16 AM
> To: ODCS; PHP General
> Cc: PHP Windows
> Subject: [PHP-WIN] session - help
>
>
> Hi,
>
> Am just a beginner to PHP, jumping from ASP. I tried re-coding from
> my small
> ASP site. And the things worked fine until I met the login page. I
> store the
> user data in sessions and access then.
>
> The logging name, mail-id, userID are stored in session vars. I
> used this
>
> > $_SESSION ["MemberName"] = "Whatever";
> $_SESSION ["MemberId"] = "Whatever";
> $_SESSION ["MemberMail"] = "Whatever";
> ?>
>
> to store the data on successful login attempt. The page redirects
> to home
> page after that. When I try to access the session var there... it
> gives a
> notice saying... the session variable is not defined?? How can I
> avoid that.
>
> I didnt do with session_start () or things like that... as we dont
> do that
> for in ASP.
>
> Thanks,
> SPS
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

__________________________________________________
Yahoo! Plus
For a better Internet experience
http://www.yahoo.co.uk/btoffer

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Sessions?

am 05.04.2007 07:47:00 von Gustav Wiberg

Hi there!

Ok, thank you for your input. A thought: In my experience, sessions have ve=
ry little impact on the server how=20
ever long you set them to live. What is your experience in this field? (how=
many users, session-variables and so on). I'm just curious! :-)

Best regards
/Gustav Wiberg


-----Original Message-----
From: Mikael Grön [mailto:php@emgee.se]=20
Sent: Wednesday, April 04, 2007 4:35 PM
To: 'php windows' (php-windows@lists.php.net)
Subject: Re: [PHP-WIN] Sessions?

Hey Gustav

It depends so much on how much data you store in the session variables,=20
what kind of storage you run (database or files and so on) and how many=20
users you have, so it's really hard to say.
In my experience, sessions have very little impact on the server how=20
ever long you set them to live.

Mike


Gustav Wiberg wrote:
> Hi there!
>
> How much impact on the server have sessions based on the length of minute=
s (seconds) that I change to? I just wonder if someone out there has=20
> Any experience of this or know a place on the web that describes this...?
>
> Best regards
> /Gustav Wiberg
>
> =20

--=20
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Sessions?

am 05.04.2007 08:28:34 von php

Hi again Gustav

We use the database model for most of our session driven sites. On one
of them we've got around 50-300 people online depending on what time it
is. On the others we don't have quite as much activity, but the server
load between them all is quite similar. There's no real difference
except for the number of MySQL connections that are made.

- Micke

Gustav Wiberg skrev:
> Hi there!
>
> Ok, thank you for your input. A thought: In my experience, sessions have very little impact on the server how
> ever long you set them to live. What is your experience in this field? (how many users, session-variables and so on). I'm just curious! :-)
>
> Best regards
> /Gustav Wiberg
>
>
> -----Original Message-----
> From: Mikael Grön [mailto:php@emgee.se]
> Sent: Wednesday, April 04, 2007 4:35 PM
> To: 'php windows' (php-windows@lists.php.net)
> Subject: Re: [PHP-WIN] Sessions?
>
> Hey Gustav
>
> It depends so much on how much data you store in the session variables,
> what kind of storage you run (database or files and so on) and how many
> users you have, so it's really hard to say.
> In my experience, sessions have very little impact on the server how
> ever long you set them to live.
>
> Mike
>
>
> Gustav Wiberg wrote:
>
>> Hi there!
>>
>> How much impact on the server have sessions based on the length of minutes (seconds) that I change to? I just wonder if someone out there has
>> Any experience of this or know a place on the web that describes this...?
>>
>> Best regards
>> /Gustav Wiberg
>>
>>
>>
>
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Sessions?

am 05.04.2007 08:35:00 von Gustav Wiberg

Hi again Mike!

Thank you very much for your input. It is appreciated! :-)

Best regards
/Gustav Wiberg
=20

-----Original Message-----
From: Mikael Grön [mailto:php@emgee.se]=20
Sent: Thursday, April 05, 2007 8:29 AM
To: ''php windows' (php-windows@lists.php.net)'
Subject: Re: [PHP-WIN] Sessions?

Hi again Gustav

We use the database model for most of our session driven sites. On one=20
of them we've got around 50-300 people online depending on what time it=20
is. On the others we don't have quite as much activity, but the server=20
load between them all is quite similar. There's no real difference=20
except for the number of MySQL connections that are made.

- Micke

Gustav Wiberg skrev:
> Hi there!
>
> Ok, thank you for your input. A thought: In my experience, sessions have =
very little impact on the server how=20
> ever long you set them to live. What is your experience in this field? (h=
ow many users, session-variables and so on). I'm just curious! :-)
>
> Best regards
> /Gustav Wiberg
>
>
> -----Original Message-----
> From: Mikael Grön [mailto:php@emgee.se]=20
> Sent: Wednesday, April 04, 2007 4:35 PM
> To: 'php windows' (php-windows@lists.php.net)
> Subject: Re: [PHP-WIN] Sessions?
>
> Hey Gustav
>
> It depends so much on how much data you store in the session variables,=
=20
> what kind of storage you run (database or files and so on) and how many=
=20
> users you have, so it's really hard to say.
> In my experience, sessions have very little impact on the server how=20
> ever long you set them to live.
>
> Mike
>
>
> Gustav Wiberg wrote:
> =20
>> Hi there!
>>
>> How much impact on the server have sessions based on the length of minut=
es (seconds) that I change to? I just wonder if someone out there has=20
>> Any experience of this or know a place on the web that describes this...=
?
>>
>> Best regards
>> /Gustav Wiberg
>>
>> =20
>> =20
>
> =20

--=20
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php