Ejemplo n.º 1
0
            public static PhpValue Gsr(Context ctx, IPhpConfigurationService config, string option, PhpValue value, IniAction action)
            {
                var sessionconfig = config.GetSessionConfiguration();

                if (sessionconfig == null)
                {
                    return(false);
                }

                switch (option)
                {
                case "session.auto_start":
                    if (action != IniAction.Get)
                    {
                        PhpException.ArgumentValueNotSupported(option, action);
                    }
                    return(sessionconfig.AutoStart);

                case "session.save_handler":
                    if (action != IniAction.Get)
                    {
                        PhpException.ArgumentValueNotSupported(option, action);
                    }
                    var handler = ctx.HttpPhpContext?.SessionHandler;
                    return(handler != null ? handler.HandlerName : PhpValue.False);

                case "session.serialize_handler":
                    return(GetSet(ref sessionconfig.SerializeHandler, "php", value, action));

                case "session.name":
                    return(GetSet(ref sessionconfig.SessionName, DefaultSessionName, value, action));

                case "session.cookie_lifetime":
                    return(GetSet(ref sessionconfig.CookieLifetime, 0, value, action));

                case "session.cookie_path":
                    return(GetSet(ref sessionconfig.CookiePath, "/", value, action));

                case "session.cookie_domain":
                    return(GetSet(ref sessionconfig.CookieDomain, "", value, action));

                case "session.cookie_secure":
                    return(GetSet(ref sessionconfig.CookieSecure, false, value, action));

                case "session.cookie_httponly":
                    return(GetSet(ref sessionconfig.CookieHttpOnly, false, value, action));

                default:
                    throw new ArgumentOutOfRangeException(nameof(option));
                }
            }