为什么不能取消会话并取消会话?

时间:2019-05-26 13:56:51

标签: php codeigniter session

我的网站上的注册系统几乎可以正常运行,唯一缺少的部分是注销功能。它启动了会话,但似乎没有破坏它,因此,上一个会话始终处于活动状态。我是在正确销毁会话还是在做完全错误的事情?

起初,我只是尝试设置用户数据,然后在销毁会话之前逐个取消设置,这是行不通的。因此,现在在销毁用户数据之前,先用普通字符串设置它们,但似乎还是行不通。

注销链接如下所示:

Traceback (most recent call last):
  File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\ptvsd_launcher.py", line 119, in <module>
    vspd.debug(filename, port_num, debug_id, debug_options, run_as)
  File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\debugger.py", line 37, in debug
    run(address, filename, *args, **kwargs)
  File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_local.py", line 64, in run_file
    run(argv, addr, **kwargs)
  File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_local.py", line 125, in _run
    _pydevd.main()
  File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\pydevd.py", line 1752, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\pydevd.py", line 1099, in run
    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
  File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\pydevd.py", line 1106, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\_pydev_imps\_pydev_execfile.py", line 25, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:\Users\groot\source\repos\PythonApplication5\PythonApplication5\PythonApplication5.py", line 145, in <module>
    brute_generator(sudoku_array)
  File "C:\Users\groot\source\repos\PythonApplication5\PythonApplication5\PythonApplication5.py", line 109, in brute_generator
    x = random.choice(possibilities)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\random.py", line 255, in choice
    def choice(self, seq):
  File "c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\microsoft\python\core\Packages\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_trace_dispatch_regular.py", line 273, in __call__
    frame_cache_key = (frame.f_code.co_firstlineno, frame.f_code.co_name, frame.f_code.co_filename)
KeyboardInterrupt

在我的控制器中,我有这个:

<a href="http://localhost/dir/dir1/dir2/index.php/Controller/logout">logout</a>

我希望会话在重定向之前会被销毁(确实如此),但是当我键入新的登录凭据时,它仍显示上一个会话的凭据,而应该显示新的会话凭据。

2 个答案:

答案 0 :(得分:2)

您可能需要按照Session is not being destroy in codeigniter的建议实施ob_start()ob_clean()。因此,这可以是同一件事的重复。

答案 1 :(得分:1)

我只是忘了指定会话参数,反正问题解决了!