Current location: Hot Scripts Forums » Programming Languages » PHP » using session_start(); on site redesign theory


using session_start(); on site redesign theory

Reply
  #1 (permalink)  
Old 07-18-03, 01:18 AM
paulj000 paulj000 is offline
Bull in a china shop
 
Join Date: Jul 2003
Location: California, USA
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
using session_start(); on site redesign theory

Hi,

I have a basic knowlege of PHP and I recently learned the basics of sessions. I will be redesigning a clients site in the near future and I am wondering if it is a good idea to simply add "session_start();" at the top of every single page as a general rule of thumb even if that particular page will not be needing any session data.

What is the general theories on this approach? Is there a smarter way to do it?

Thank you
Reply With Quote
  #2 (permalink)  
Old 07-18-03, 08:02 AM
Chris Boulton Chris Boulton is offline
Wannabe Coder
 
Join Date: Jun 2003
Location: Sydney, Australia
Posts: 208
Thanks: 0
Thanked 0 Times in 0 Posts
If you are going to be using similar code (eg session_start() and also code to handle the sessions on each page), you should use a require/include statement in each file..

The included file should contain what you need to do to check your sessions and build the main header and footer for the site.

This reduces a lot of code, and will make it easier for you to follow.

Just my bit

Chris
__________________
Chris Boulton
SurfiOnline!
MyBulletinBoard
Reply With Quote
  #3 (permalink)  
Old 07-19-03, 02:58 AM
SleeperZ SleeperZ is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
I agree with Chris. If your going to be doing anything in particular with the sessions before the actual page.... put that all into a file, and then include / require it into each page..

It will make changing something later a lot easier. It also saves copying and pasting. :-)
__________________
***Expect the Unexpected***
Reply With Quote
  #4 (permalink)  
Old 07-19-03, 05:33 PM
paulj000 paulj000 is offline
Bull in a china shop
 
Join Date: Jul 2003
Location: California, USA
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks guys,

Is there ever a reason why you would NOT want to have it on every page? (via include file or whatever)

It seems like one of those "set it and forget it" things. Just make sure it gets in there and if you ever need it, it's there. Right?


- Paul
Reply With Quote
  #5 (permalink)  
Old 07-19-03, 08:00 PM
SleeperZ SleeperZ is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Pretty much, if you have session_start() on the start of every page, that means you can do calls to functions etc that may use some session variables.

If you dont have it there, you could be forever trying to work out "why isnt it working?!?"

It has happened to me before :-$
__________________
***Expect the Unexpected***
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Too bad for webmaster who were stealing idea from another site - Look ! kevin PHP 3 02-18-04 11:24 AM
I am working on a site and need suggestions coolgy768 Script Requests 1 09-10-03 02:01 PM
I developed a site .... Adi New Members & Introductions 3 08-23-03 11:02 AM
Does anyone know what type of script this site uses The Probuilder Script Requests 3 08-22-03 02:03 PM
Review a RPG site MGCJerry Website Reviews 14 06-19-03 10:29 AM


All times are GMT -5. The time now is 10:32 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.