homepage Welcome to WebmasterWorld Guest from 54.205.168.88
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP session.save_path
Use a MySQL table...
DrDoc




msg:1294859
 7:11 am on Mar 25, 2003 (gmt 0)

How do I specify a database table for session.save_path?

 

andreasfriedrich




msg:1294860
 11:09 am on Mar 25, 2003 (gmt 0)

Have a look at Session Tracking: Part 2 [onlamp.com].

Andreas

DrDoc




msg:1294861
 2:56 pm on Mar 25, 2003 (gmt 0)

Thank you!

DrDoc




msg:1294862
 3:11 pm on Mar 25, 2003 (gmt 0)

Can I somehow include that in .htaccess?

andreasfriedrich




msg:1294863
 7:05 pm on Mar 25, 2003 (gmt 0)

You may want to add the following lines to a .htaccess file:


php_value session.save_handler user
php_value auto_prepend_file [php.net] "/path/to/file/with/session/code.PHP [php.net]"

This will save you the work of having to include [php.net] the session code on every page.

Andreas

DrDoc




msg:1294864
 7:37 pm on Mar 25, 2003 (gmt 0)

aah! :)

Thanks... again!

DrDoc




msg:1294865
 7:48 pm on Mar 25, 2003 (gmt 0)

In the example (onlamp page) you showed me, it has the following:

mysql_session_open($session_path,$session_name) {
...
}

$session_name can be whatever I want (right?) but what about $session_path? What is that supposed to be?

DrDoc




msg:1294866
 7:53 pm on Mar 25, 2003 (gmt 0)

The two input parameters $session_save_path and $session_name refer to the configuration directives found in the php.ini.

But... the save path is what I want to change!?

<confused>

andreasfriedrich




msg:1294867
 8:27 pm on Mar 25, 2003 (gmt 0)

mysql_session_open is just a callback function that gets called by PHP [php.net] when a session is opened. PHP [php.net] is so nice as to pass the two $session_save_path and $session_name parameter to your callback function. If you donīt want to use them then donīt. However it is probably good style to use $session_save_path to configure the name of the database and $session_name to configure the table. That way you will not have to change your session code but can simply use the normal php_value/ini_set [php.net] configuration mechanism to use different databases and tables.

So you would do a [url=http://www.php.net/mysql_connect]mysql_connect[/url]($session_save_path); and [url=http://www.php.net/mysql_select_db]mysql_select_db[/url]($session_name);.

In your .htaccess file you would then specify the name of the db and table like so:


php_value session.save_path "mydb"
php_value session.name "mytable"

Andreas

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved