# Alternative implementation of session state

**URL:** <https://discuss.streamlit.io/t/alternative-implementation-of-session-state/799>\
**Category:** Using Streamlit\
**Tags:** cache, session-state\
**Created:** [October 29, 2019, 11:07am UTC](https://discuss.streamlit.io/t/alternative-implementation-of-session-state/799 "2019-10-29T11:07:17Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![avn3r](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/avn3r/32/913_2.png) [@avn3r](https://discuss.streamlit.io/u/avn3r)\
**Post date:** [December 18, 2019, 4:38pm UTC](https://discuss.streamlit.io/t/alternative-implementation-of-session-state/799/7 "2019-12-18T16:38:49Z")

</div>

A more generic solution for Classes which the only downside is that all parameters must be initialized with default values.

```auto
def MyClass:
    __init__ (self, a=None, b=None):
        self.a = a
        self.b = b

def get_class(class_, **kargs):
    return class_(**kargs)

```

Example:  
`my_class = get_state(get_class, class_=MyClass, a=a, b=b)`

@biellls thanks for so useful functions 😃

---

_[View the full topic](https://discuss.streamlit.io/t/alternative-implementation-of-session-state/799)._
