Concept : WebServer and sessions

Everything else that doesn't fall into one of the other PB categories.
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Concept : WebServer and sessions

Post by Progi1984 »

Hi,
for a new project, i begin the reflexion. I need a webserver which need sessions.
I have some ideas :
when a user connects to the server, that creates an input in a base ( why not a linked list ?), with its IP and name and access level and state. If its password is correct, then its state is "accepeted".
But i want to do admin and moderator which have access at differents pages, how can i do in purebasic ?

PS : my users and password will be stored in a pb database !
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

The standard way would be store the password client-side in a cookie. Then have all users in a database. Filtering by IP is not good since many computers on a LAN can have the same public IP.
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

How do Apache manage sessions ?

is there a way of managing sessions on the server side ?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Apache does not manage sessions, so I cannot answer that question.

You need to use cookies to manage sessions unless you keep the connection open (which you do not want to do on a webserver).
ShotGun Jack
User
User
Posts: 23
Joined: Tue Oct 14, 2003 1:16 am
Location: NC, USA
Contact:

Post by ShotGun Jack »

Trond wrote:You need to use cookies to manage sessions unless you keep the connection open (which you do not want to do on a webserver).
Could u elaborate on this. What do you mean by an open connection. Juz wandering if I need to force a CloseNetworkConnection. If u have a page with say 10 images. You will probably get 11 client requests from a page load. Unused connections time out after while (I'm talking PB code)
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

The client closes the connection when it has received all the data it requested, I think.

You cannot use a constantly open connection in a web/http environment, you would have to write your own client and server.
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

But the problem of cookies is that the client must accept them !
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Progi1984 wrote:But the problem of cookies is that the client must accept them !
Yes. But the problem with not using cookies it that the use must enter the username and password on every page.

You can carry the username and password (hashed/encrypted?) in the url if you do not want to use cookies.
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

After searching, you have all right :D

The two ways of managing sessions are with cookies and via URL (putting an ID for a user in all URLs).

But a question is always here : How do Apache and PHP manage sessions ?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Apache does not manage sessions. PHP uses cookies.
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

Excuse me (for Apache) : when i have an idea in the head ... :roll:

OK ! So the problem is none now !
Thank you very much
Post Reply