文字

session_abort

(PHP 5 >= 5.6.0)

session_abortDiscard session array changes and finish session

说明

void session_abort ( void )

session_abort() finishes session without saving data. Thus the original values in session data are kept.

返回值

没有返回值。

参见

  • $_SESSION
  • The session.auto_start configuration directive
  • session_start() - 启动新会话或者重用现有会话
  • session_reset() - Re-initialize session array with original values
  • session_commit() - session_write_close 的别名

用户评论:

[#1] parsa dot mhn at outlook dot com [2015-09-03 14:33:51]

To better understand this function you should execute this code first :

<?php
    
// First of all choose your path , For e.g. C:/session
    
session_save_path('Your Path here !');
    
    
session_start();
    
    
// Define a Session Variable
    
$_SESSION['Key'] = 'value' ;
    
    
Var_dump(session_status() == PHP_SESSION_ACTIVE);
    
    
// Output : bool(True) , it means you have an open session !
?>


Then you should execute this code :

<?php
    
// Choose the path that you used it in first part  
    
session_save_path('Your path here');
    
    
session_start();
    
    
// If you want to close session and keep your original data in your path , you should use session_abort()
    
session_abort();
    
    
var_dump(session_status()== PHP_SESSION_ACTIVE);
    
    
// Output : bool(False) , it means your session closed .
?>


So if you have an open session , session_abort() will simply close it without effecting the external session data , so you can reload your data again from your path that you chose .

上一篇: 下一篇: