Home

Forums

Web development

 

 

 

 
     
 
dna88 Web development and Technology Forum
 
Profile   Register   Memberlist   Usergroups   FAQ   Search  Log in
Data persistency with PHP. Session management.

 
Post new topic   Reply to topic    dna88 Forum Index -> Web scripting language Discussion Forum
Author Message
dude
Power User
Power User


Joined: 10 Mar 2004
Posts: 376
Location: Savar, Dhaka

Post Post subject: Data persistency with PHP. Session management. Reply with quote

I have a question from a friend who is just learning PHP and web design stuffs. Data persitency. How do you maintain data persistency with php? From one web page to another web page, how do you keep track of data or transfer data from one web page to next web page?

Example: in this forum how does it follow me when I post a mesage and move from one forum to another? How does the php code remember me or recognise that it was me for every session after I log in? Also it can remember my log in information. How does the php do that?
Mon Jul 12, 04 12:26 am
Back to top
dude View user's profile Send private message Visit poster's website
quantum
Site Admin
Site Admin


Joined: 07 Mar 2004
Posts: 1048
Location: Dhaka, Bangladesh

Post Post subject: Taking the data with you in php! Reply with quote

The answer is kind of long though not complicated. Ermm.. yeah it gets kind of complicated when you are talking about somewhat complex session management that goes on a forum like this phpbb board.

In its most simple case data can be passed from one page to another via form. Those submits buttons you click passes variables from one page to another.

Php can issue a global variable and carry the variable from one page to another. But global variables have some security issues, so it is not used very often.

Php can use a cookie to store data in the user's computer and than retrieve and use it as necessary.

Php can use something called a session variable. You can assign a session id for as many variables as you wish. Then call the session and use the variable anytime you wish. Very neat! Here is a simple example of session handling:

Set php session variables:

Code:
session_start();
$_SESSION['variableName1'] = "value1";
$_SESSION['variableName2'] = "value2";
session_write_close(); 


Retrieve php session variables

Code:
session_start();
$gimmeVar1 = $_SESSION['variableName1'];
$gimmeVar2 = $_SESSION['variableName2'];
session_write_close(); 


Very easy. Save the php session id and the related variables in a database if you wish. By default the php zend engine itself handles the session.

Well that's about the summary. If you are interested about any particular method we can discuss even more details.
_________________

Dust fills my eyes / Clouds roll by / and I roll with them / Centuries cry / Orders fly / and I fall again
Afford best design, implement best solution. Outsource your web design.
Tue Jul 13, 04 8:39 am
Back to top
quantum View user's profile Send private message Visit poster's website AIM Address
dude
Power User
Power User


Joined: 10 Mar 2004
Posts: 376
Location: Savar, Dhaka

Post Post subject: Reply with quote

I would like to know more about sessions.
Sat Jul 17, 04 1:00 am
Back to top
dude View user's profile Send private message Visit poster's website
dude
Power User
Power User


Joined: 10 Mar 2004
Posts: 376
Location: Savar, Dhaka

Post Post subject: Need info on how to use session in php Reply with quote

Hey quantum, you seem to have forgotten about some more information on sessions in php. I need that. So pretty please...
Fri Aug 13, 04 7:35 am
Back to top
dude View user's profile Send private message Visit poster's website
quantum
Site Admin
Site Admin


Joined: 07 Mar 2004
Posts: 1048
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

Hi dude,

I am extremely sorry. Please give us a few days to get some multimedia stuffs sorted out. Then I will be back in php mode again. I hope you are not in a hurry.
_________________

Dust fills my eyes / Clouds roll by / and I roll with them / Centuries cry / Orders fly / and I fall again
Afford best design, implement best solution. Outsource your web design.
Sat Aug 14, 04 10:06 am
Back to top
quantum View user's profile Send private message Visit poster's website AIM Address
dude
Power User
Power User


Joined: 10 Mar 2004
Posts: 376
Location: Savar, Dhaka

Post Post subject: Php session questions Reply with quote

It is alright. I understand. I am not in a hurry. So take your time.
Sat Aug 14, 04 1:32 pm
Back to top
dude View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    dna88 Forum Index -> Web scripting language Discussion Forum All times are GMT - 7 Hours
Page 1 of 1

 

Partners and Resources

Bangladesh hosting company

Bangladesh web design

Driven by phpBB © phpBB Group