Session questions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Xelmepa
Forum Commoner
Posts: 41
Joined: Sat Aug 24, 2002 3:02 pm
Location: Athens, Greece
Contact:

Session questions

Post by Xelmepa »

Hi,
I'm relatively new to PHP. Writing small scripts, at some point I realised I needed a login script. I started reading tutorials and the manual about sessions, and I have a few questions:

1. Can you end a session?
Besides session_destroy(); which unsets all the vars/array(s).

2. Do you need to manually set cookies or does session_start(); do that?
Also, does the cookie have info realtive to the script or some sort of way to identify which script started the session?

I am asking this because if I used session_start(); in any window of the browser that had dealt with another session in my scripts (in the short past of some minutes), session_start(); would use the existing session.

It sortof gave me the feeling that any (php) script that I would enter in that browser would use the same session(!) , something that I hope is not true.
Please someone with a good deal of knowledge on sessions explain!

Thanks a lot in advance,
Xelmepa.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

1. To end an session you use use both session_destroy(); and session_unset();

2. Sessions in default does not use cookies they store the information in the specified folder which is set in php.ini. Also you would not know which file has started the session but the session cannot be used by any other sites.
User avatar
Xelmepa
Forum Commoner
Posts: 41
Joined: Sat Aug 24, 2002 3:02 pm
Location: Athens, Greece
Contact:

Post by Xelmepa »

1. Those 2 really just unset the vars but it's the same I guess...

I probably had those Qs cuz I didn't really mess enough with sessions to find out myself :P

Thanks dude

Cheers :) ::drinks diet coke.
Post Reply