Do I always have to do session_start()???

SpaceshipSpaceship
Watch

PoorDoggie

Soon to be RICHdoggie!VIP Member
Impact
18
Do I always have to do session_start, even on pages I don't want to use any session variables? Will it still remember all the variables?

Thanks
Tom
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Hello,

You only need to really use it if you plan on calling a $_SESSION['variable'] to get what the session contains.

- Steve
 
0
•••
thanks - its not going to forget that variable if I don't use it though?
 
0
•••
It won't forgot them, I do not believe.. unless you did a session_destory, unset, or $_SESSION = array(); to kill it. I'm not sure, however. I've not worked w/sessions much tbh.
 
0
•••
thanks a lot - am just about to launch into a whole user script for 6yd.net. Am making a few different things for it that will run off a user database. My goodness it looks complicated though! :( well... wish me luck - may be back for more help later!
 
0
•••
it really depends on wether the user is using cookies or not. I beleive if the user has cookies turned off (and as such the url is appended with the session variable) then there will be no way for the server to know which session it is and will start a new 1.
 
0
•••
filth@flexiwebhost said:
it really depends on wether the user is using cookies or not. I beleive if the user has cookies turned off (and as such the url is appended with the session variable) then there will be no way for the server to know which session it is and will start a new 1.
so if I have a session variable $_SESSION['name'] - it will append my url with:

script.php?name=filth@...???
 
0
•••
If you don't put it on the top of all pages, you will probably see some inconsistancies.
 
0
•••
so you are saying, put it there anyway?
 
0
•••
PoorDoggie said:
so if I have a session variable $_SESSION['name'] - it will append my url with:

script.php?name=filth@...???

no it doesnt append the url with the session variables it will append it with the session name and session id so it would look something like:-
Code:
page_name.php?sid=82cf054ebb3f3a88d9e4a4c4668cd9f7

if you look in the servers temp folder you will see a file called 82cf054ebb3f3a88d9e4a4c4668cd9f7 which stores the session variables.

All of this of course really depends on the server configuration.
 
0
•••
oh right. So there is always a sid?

Thanks
Tom
 
0
•••
yes there is always a sid (session ID) otherwise the server would have no way of recognising which session the person is using. The url is ussually only appended IF the user has cookies disabled but this behaviour can be changed in the php.ini file (or using ini_set()
 
0
•••
oh right. Would there be any point doing that though? Would I ever need to use a session id?
 
0
•••
i take it you mean changing the behaviour of the sessions. Yes 1 possible reason is if you do not want to issue cookies.

Again if the user has cookies disabled and your server doesnt have session.use_trans_sid enabled the user will not be able to traverse your site properly if it relies on sessions.
 
0
•••
how would I get round that?

I am hosted with an external hosting company... do you think that use_trans_sid would be enabled? Is there any reason that they would turn it off?

Thanks
Tom
 
0
•••
easiest way to find out is to create a phpinfo page:-

PHP:
<?PHP
phpinfo();
?>

the chances are it is already enabled as there is no reason for a host to disable it and would cause alot of problems if they did.
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back