?
Solved

Where does session_name() value come from?

Posted on 2012-08-18
9
Medium Priority
?
839 Views
Last Modified: 2012-08-23
I am debugging some code in Joomla and I don't understand how session_name() generates a value.

There is a line
$session_name = session_name();

Open in new window


$session_name value is set to a string "ee575..."

Where does this string come from and how is it generated?
0
Comment
Question by:SAbboushi
  • 4
  • 3
  • 2
9 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38308716
See here: http://us3.php.net/manual/en/function.session-name.php  and here: http://us3.php.net/manual/en/session.configuration.php#ini.session.name  Defaults to PHPSESSID which is the default value set in 'php.ini'.
0
 

Author Comment

by:SAbboushi
ID: 38308877
Thanks Dave - I didn't find anything on those pages that explains where the session_name value comes from.
0
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 800 total points
ID: 38308889
You're trying too hard.  The default value is one of the entries in 'php.ini' under 'session.name'.  session_name() returns that value.  If you put a value in it like session_name('newsession') you can change it but then it is up to you to keep track of it.  If you are getting something other than PHPSESSID, then Joomla is probably changing it.  I have changed it on my Linux servers. http://us2.php.net/manual/en/function.session-name.php
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Accepted Solution

by:
Marco Gasi earned 1200 total points
ID: 38308909
If you look at session.php file (you should find it in joomla/libraries/joomla/session folder), you can see session_name function is used 6 times: the last one it is used to set a new (no default) session name:

line 719: session_name(md5($options['name']));

Cheers
0
 

Author Comment

by:SAbboushi
ID: 38321829
Thanks marqusG -- I now see that session_name was originally set to PHPSESSID (thanks Dave) and then is changed by line 719.  Since the value of 'name' is 'site', it seems that the session_name will be the same for all joomla users when accessing a joomla site, i.e.

1) won't the md5 hash of the string "site" always be the same i.e. "ee575..."?
2) So I suspect somewhere later, joomla will execute a php command that will assign a unique session ID to this session name?

Thanks for your help
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38322087
1. Yes it should be the same unless something else is added to change it.
2. The 'session_start()' function is supposed to create the unique session_id value.  'session_start()' is normally at the top of every page that is part of the session though there may be a line or two above it when you are using a different session_name.
0
 

Author Comment

by:SAbboushi
ID: 38322326
Thanks Dave!
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38322579
You're welcome.
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 38328133
I came back now from a litle three days holiday: I'm glad to help you. Good luck with your project

Cheers
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question