Welcome to WebmasterWorld Guest from 54.226.27.104

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP session.save_path

Use a MySQL table...

     

DrDoc

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

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

andreasfriedrich

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

WebmasterWorld Senior Member 10+ Year Member



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

Andreas

DrDoc

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

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Thank you!

DrDoc

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

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Can I somehow include that in .htaccess?

andreasfriedrich

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

WebmasterWorld Senior Member 10+ Year Member



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

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

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



aah! :)

Thanks... again!

DrDoc

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

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month