<commit_before># 14.2 Session

Chapter VI, when we saw how to use the Go language session, also achieved a sessionManger, beego sessionManager based framework to achieve a convenient session handling functions.

## Session integration
beego mainly in the following global variables to control the session handling:

	// related to session
	SessionOn bool	// whether to open the session module, the default is not open
	SessionProvider string	// session backend processing module provided, the default is sessionManager supported memory
	SessionName string	// client name saved in cookies
	SessionGCMaxLifetime int64	// cookies validity

	GlobalSessions *session.Manager// global session controller

Of course, the above values of these variables need to be initialized, you can also follow the code to match the configuration file to set these values:

	if ar, err := AppConfig.Bool("sessionon"); err != nil {
		SessionOn = false
	} else {
		SessionOn = ar
	}
	if ar := AppConfig.String("sessionprovider"); ar == "" {
		SessionProvider = "memory"
	} else {
		SessionProvider = ar
	}
	if ar := AppConfig.String("sessionname"); ar == "" {
		SessionName = "beegosessionID"
	} else {
		SessionName = ar<commit_msg>Fix translation for intro to 14.2.md<commit_after># 14.2 Sessions

In chapter 6, we introduced some basic concepts pertaining to sessions in Go, and we implemented a sessions manager. The Beego framework uses this session manager to implement some convenient session handling functionality. 

## Session integration
beego mainly in the following global variables to control the session handling:

	// related to session
	SessionOn bool	// whether to open the session module, the default is not open
	SessionProvider string	// session backend processing module provided, the default is sessionManager supported memory
	SessionName string	// client name saved in cookies
	SessionGCMaxLifetime int64	// cookies validity

	GlobalSessions *session.Manager// global session controller

Of course, the above values of these variables need to be initialized, you can also follow the code to match the configuration file to set these values:

	if ar, err := AppConfig.Bool("sessionon"); err != nil {
		SessionOn = false
	} else {
		SessionOn = ar
	}
	if ar := AppConfig.String("sessionprovider"); ar == "" {
		SessionProvider = "memory"
	} else {
		SessionProvider = ar
	}
	if ar := AppConfig.String("sessionname"); ar == "" {
		SessionName = "beegosessionID"
	} else {
		SessionName = ar
{'fraction_non_alphanumeric': 0.07071112896745681, 'fraction_numerical': 0.00562474889513861, 'mean_word_length': 4.343347639484978, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1290484', 'n_tokens_mistral': 652, 'n_tokens_neox': 620, 'n_words': 300}