title: secret key not set in flask session, using the Flask-Session extension
body: <p>Right now I am using a flask 3rd party library <a href="https://flask-session.readthedocs.io/en/latest/" rel="noreferrer">Flask-Session</a> and I am having no luck getting a session working.</p>
  <p>When I connect to my site, I get the following error:</p>
  <blockquote>
  <p>RuntimeError: the session is unavailable because no secret key was
  set. Set the secret_key on the application to something unique and
  secret.</p>
  </blockquote>
  <p>Below is my server code.</p>
  <pre><code>from flask import Flask, session
  from flask.ext.session import Session
  
  SESSION_TYPE = 'memcache'
      
  app = Flask(__name__)
  sess = Session()
  
  nextId = 0
  
  def verifySessionId():
      global nextId
  
      if not 'userId' in session:
          session['userId'] = nextId
          nextId += 1
          sessionId = session['userId']
          print (&quot;set userid[&quot; + str(session['userId']) + &quot;]&quot;)
      else:
          print (&quot;using already set userid[&quot; + str(session['userId']) + &quot;]&quot;)
      sessionId = session.get('userId', None)
      return sessionId
  
  @app.route(&quot;/&quot;)
  def hello():
      userId = verifySessionId()
      print(&quot;User id[&quot; + str(userId) + &quot;]&quot;)
      return str(userId)
  
  if __name__ == &quot;__main__&quot;:
      app.secret_key = 'super secret key'
  
      sess.init_app(app)
  
      app.debug = True
      app.run()
  </code></pre>
  <p>As you can see, I do set the app secret key. What am I doing wrong?</p>
  <p>Are there other session options?</p>
  <p>Other info:
  Running Python 2.7 on Linux Mint</p>
  <p>Full paste:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/home/sean/code/misc/hangman/venv/lib/python2.7/site-packages/flask/app.py&quot;, line 1836, in __call__
      return self.wsgi_app(environ, start_response)
    File &quot;/home/sean/code/misc/hangman/venv/lib/python2.7/site-packages/flask/app.py&quot;, line 1820, in wsgi_app
      response = self.make_response(self.handle_exception(e))
    File &quot;/home/sean/code/misc/hangman/venv/lib/python2.7/site-packages/flask/app.py&quot;, line 1403, in handle_exception
      reraise(exc_type, exc_value, tb)
    File &quot;/home/sean/code/misc/hangman/venv/lib/python2.7/site-packages/flask/app.py&quot;, line 1817, in wsgi_app
      response = self.full_dispatch_request()
    File &quot;/home/sean/code/misc/hangman/venv/lib/python2.7/site-packages/flask/app.py&quot;, line 1477, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File &quot;/home/sean/code/misc/hangman/venv/lib/python2.7/site-packages/flask/app.py&quot;, line 1381, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File &quot;/home/sean/code/misc/hangman/venv/lib/python2.7/site-packages/flask/app.py&quot;, line 1475, in full_dispatch_request
      rv = self.dispatch_request()
    File &quot;/home/sean/code/misc/hangman/venv/lib/python2.7/site-packages/flask/app.py&quot;, line 1461, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File &quot;/home/sean/code/misc/session/sessiontest.py&quot;, line 27, in hello
      userId = verifySessionId()
    File &quot;/home/sean/code/misc/session/sessiontest.py&quot;, line 16, in verifySessionId
      session['userId'] = nextId
    File &quot;/home/sean/code/misc/hangman/venv/lib/python2.7/site-packages/werkzeug/local.py&quot;, line 341, in __setitem__
      self._get_current_object()[key] = value
    File &quot;/home/sean/code/misc/hangman/venv/lib/python2.7/site-packages/flask/sessions.py&quot;, line 126, in _fail
      raise RuntimeError('the session is unavailable because no secret '
  RuntimeError: the session is unavailable because no secret key was set.  Set the secret_key on the application to something unique and secret.
  </code></pre>