Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

simple question about session

General discussions related to php

Moderators: macek, egami, gesf

simple question about session

Postby youpi » Sat Mar 22, 2003 12:24 pm

hi,

I am using sessions in my php scripts because i read it worked even if the user doesn't accept the cookies.

But i read another article recently that said that for each session a cookie was created to contain the id session.

Hope someone can help me .

thanks
youpi
New php-forum User
New php-forum User
 
Posts: 9
Joined: Tue Jan 28, 2003 10:20 am

Postby quelle » Mon Mar 24, 2003 11:07 pm

Basically, whenever a session is started, a temp file (cookie) is created on the server side which is identified by a randomly generated sessionID (PHPSESSID) and contains a session's information (registered variables and their values).
Eg. The file sess_f828da0ce39572a81e4a803d10928150 contains : logged_id|i:0;css_file|s:13:"mainstyle.css";msg|s:0:"";

In order for the client system to make use of these variables, it must know which temp file it "owns". The same sessionID gernerated earler must be stored on the client side somehow and made available to each page that needs to use the session variables. If the client "knows" the sessionID, then it knows which tempfile it "owns" on the server. You can do this two ways:

1. passing it from page to page using a client-side cookie which stores nothing but the sessionID
Eg. The file: blahblah_temp contains: f828da0ce39572a81e4a803d10928150

2. or passing it via GET/POST variables (in the URL)
Eg. blahpage.php?PHPSESSID=f828da0ce39572a81e4a803d10928150

The latter form is not as secure but allows you to work around users that do not allow cookies. Here's a good explanation of the difference: http://www.fluidthoughts.com/howto/php/sessions/

Hope this helps!
quelle
New php-forum User
New php-forum User
 
Posts: 8
Joined: Tue Aug 20, 2002 11:57 am

Postby youpi » Wed Mar 26, 2003 4:49 am

hi,

thanks for your reply

:D
youpi
New php-forum User
New php-forum User
 
Posts: 9
Joined: Tue Jan 28, 2003 10:20 am


Return to PHP General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.