Current time: 12-24-2024, 12:11 PM Hello There, Guest! (LoginRegister)


Post Reply 
Add custom $_SESSION vars
Author Message
Max13 Offline
Junior Member
*

Posts: 11
Joined: Jul 2009
Reputation: 0
Post: #1
Add custom $_SESSION vars
Hi everybody,

I've just done the upgrade to 1.0.7 final.
I'm adding some custom pages for a shell hosting i'm making.

I want to be able to be able to modify the session params, for example, making the session available for 24 Hours by default, and "$_SESSION['ok']"
(.../gui/include/ispCP/Initializer.php):
PHP Code:
session_name('ispCP');
session_set_cookie_params(86400); // 24 hours
if (!isset($_SESSION)) {
    
session_start();


I think it's working.

But... I want to add such a params directely in a script (.../gui/index.php):
PHP Code:
$_SESSION['ok'] = 1;
print_r($_SESSION); 

Unfortunately, this is only showing:
Code:
Array
(
    [user_def_lang] => lang_FrenchFrance
    [user_theme] => omega_original
)

Any idea of why my own params are not "available", even if I put them on "environment.php", "Initializer.php", "ispcp-lib.php", or even directely in a page ?

Thank you for your help.
11-30-2010 09:24 PM
Find all posts by this user Quote this message in a reply
Max13 Offline
Junior Member
*

Posts: 11
Joined: Jul 2009
Reputation: 0
Post: #2
RE: Add custom $_SESSION vars
up ? =)
12-02-2010 07:04 AM
Find all posts by this user Quote this message in a reply
motokochan Offline
Member
***

Posts: 274
Joined: Jul 2008
Reputation: 1
Post: #3
RE: Add custom $_SESSION vars
It's because session_set_cookie_params() is setting internal PHP variables about a session cookie, it's not actually adding items to the $_SESSION superglobal array. If you want to see these details, you should use session_get_cookie_params(). It's a better idea to set these in php.ini as otherwise every page that handles the session needs that function called.

Also, keep in mind that having such a long session length is a bad idea for security. Remember that the expiration is reset on each use of the session, so 24 hours means that it'll be kept active for 24 hours after the last action.
12-04-2010 01:57 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)