Alternative to sessions

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
manoj
Regular
Posts: 49
Joined: Tue Sep 05, 2006 12:20 pm

Alternative to sessions

Post by manoj »

Hi,

Is there any alternative to using sessions in serendipity. As per our project's requirements, session cannot be maintained because the project is on multiple servers for load balancing. Instead of using session_start() and $_SESSION is there any other alternative.

Thanks and Regards,
Manoj
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Alternative to sessions

Post by garvinhicking »

Hi!

You can use the various PHP session drivers, which also make sessions available via DB handlers.

Or you can write your own PHP session handler, that Serendipity will be able to use, because it always uses what's registered to PHP as default.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
manoj
Regular
Posts: 49
Joined: Tue Sep 05, 2006 12:20 pm

Post by manoj »

Hi,

If any of the session handlers, for example, DB handler is used, then what is the amount of code changes that can happen. Can u provide us an approximate percentage of changes if DB Handler is used.

Thanks and Regards,
Manoj
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

No code of Serendipity needs to change, you just need to change the PHP configuration and/or maybe include your custom session handler script via serendipity_config_local.inc.php.

All s9y session write and read calls stay the same because they use the PHP API.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
manoj
Regular
Posts: 49
Joined: Tue Sep 05, 2006 12:20 pm

Post by manoj »

Hi,

I have two more doubts regarding this session handling. Please provide a clarification.

1. What is the scope of $serendipity variable? Where is it defined? $serendipity is defined as 'global' in many functions.

2. How is session handled when application is placed in two different servers for load balancing.

If we comment session_start() in serendipity_config.inc.php and use a global array variable $_SESSION for handling session data, will it work?

Thanks and Regards,
Manoj
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
1. What is the scope of $serendipity variable? Where is it defined? $serendipity is defined as 'global' in many functions.
$serendipity is declared on the global level, so only functions need to import it into their local scope by using the 'global' keyword. $serendipity is not a superglobal, because PHP supports no custom superglobals.

$serendipity is defined in include/compat.inc.php in the first few lines, and filled in many other files that are included later.
2. How is session handled when application is placed in two different servers for load balancing.
That depends on your implementation of the session handling. If you use a central session storage, then the sessions are shared across load balancing servers.
If we comment session_start() in serendipity_config.inc.php and use a global array variable $_SESSION for handling session data, will it work?
[/uote]

That depends on how you think to make $_SESSION persist between request and shared across servers. If you simply make $S_ESSION a global variable, it will be destroyed after each request, and thus not be a session variable that holds contents accross requests. ;)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply