HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
How to create session in PHP?
Post new topic   Reply to topic    HTML Help Forum Index -> PHP
View previous topic :: View next topic  
Author Message
openxmod



Joined: 19 Sep 2008
Posts: 1

PostPosted: Fri Sep 19, 2008 4:19 am     How to create session in PHP? Reply with quote

i want to create session in php site?
how do to it?
Daler



Joined: 23 May 2008
Posts: 53

PostPosted: Fri Sep 19, 2008 7:11 am     Reply with quote

Create your session with (edit where applicable):
Code:

session_save_path("/home/users/web/b786/d5.anythingweb/phpsessions");
session_start();

Define session parimeters afterwards.

And then define your session:
Code:

$_SESSION['*please change*'] = *please change*);


I'm not 100% certain that's right, I took it from a CAPTCHA script that I made using a tutorial, so you could give it a go, see if it works.
Newbie101



Joined: 09 Oct 2008
Posts: 35

PostPosted: Thu Oct 16, 2008 8:37 am     I created in depth explanation Reply with quote

I'm a newbie, and find the world of Sessions confusing. Or I did....

In my thread "pass 1 value 2" I used Sessions as my easiest answer, and have simple working code for what works.

It is important to put

Code:
<?php
session_start();   
?>

at the beginning of your page. Also the page needs to be a .php page. I think any newbies who are looking for this answer could find it on my thread.
amitpatekar



Joined: 23 Oct 2008
Posts: 3

PostPosted: Thu Oct 23, 2008 11:05 pm     Re: I created in depth explanation Reply with quote

Hi, All,
Sessions are wonder full feature of php and its inbuilt.
One can just write
Code:
session_start();
and the session will start. Session are stored on server side. HTTP protocol is state less protocol so, we need to use session to keep track which user is doing what.
Unique Session ID is assigned to each user who has logged in to the website and session start is executed.

One this should be keep in mind that the session_start(); should be the first line in the php file.
See Tutorials on Website Development.

You can register a variable in session using following code
Code:
$_SESSION['variable_name']="some value"


For more tutorials on php sessions visit WebWorldGuru.com[/url]
npsari



Joined: 27 Oct 2008
Posts: 3

PostPosted: Wed Nov 05, 2008 4:44 am     Reply with quote

I use sessions in one of my sites

I simply included a session in the top menu, so that it stays in all pages

Code:
<?php
session_start();   
?>


It has to be the start before you put <HTML> tags
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> PHP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial