0

I'm coming from php so I know that

$_SESSION['variable'] = 55

Can be modified from between pages and is not depending on an external file being imported to do.

How do I do this with python? I am using .cgi scripts.

Googling around brings me to this idea of using a file which stores values across files but the changes only to the original file will be felt globally any other changes are local.

For example, the suggestion is:

config.py

variable = 5

otherfile.py

import config

print config.variable
config.variable = 3

I don't think this will give me the result that I want. I don't think the changes in otherfile will pass to a different file I made.

munchschair
  • 1,593
  • 3
  • 19
  • 43
  • This question is unanswerable without knowing what web framework you are using. – Daniel Roseman Dec 20 '15 at 20:51
  • I'm not using any. I am just writing with python .cgi. I run my code in apache 2. Do I need a framework? I was thinking flask or django might have some function that does this. – munchschair Dec 20 '15 at 20:52
  • 2
    Yes, even without this question; you shouldn't use CGI anyway. If you want to do anything non trivial then definitely. All frameworks will have some kind of session functionality. – Daniel Roseman Dec 20 '15 at 20:55
  • Thanks. I'll be looking into one. – munchschair Dec 20 '15 at 21:05
  • Can I still use my preexisting CGI files with other frameworks like flask or django or will I have to change the filenames and paths? – munchschair Dec 20 '15 at 21:08

0 Answers0