如何通过Tomcat和PHP之间的会话 [英] How to pass a session between tomcat and php

查看:191
本文介绍了如何通过Tomcat和PHP之间的会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我在工作的一个jsp的tomcat服务器上,并试图通过会话数据(用户ID等),PHP中的WTF code的情况。我计划重写PHP会话使用的session_set_save_handler处理()
我的问题是在哪里呢tomcat的把它存储会话数据(硬盘?)和它使用的是什么样的编码?
还是我在错误的道路上?
我知道糖化PHP和JSP是愚蠢刚刚得到这个任务,我太生气的想法。

Hey, I am in a WTF code situation working on a jsp tomcat server and trying to pass session data (user id, etc.) to php. i am planning to rewrite php session handling with session_set_save_handler() my question is where does tomcat stores it session data (harddrive?) and what kind of encoding does it uses? or am i on the wrong path? i know the idea of mashing php and jsp is stupid just got this assignment and i am pissed too.

推荐答案

尽量避免在不同系统之间的会话。你真的不能共享PHP和Java之间的会话,因为

Try to avoid sessions between different systems. You can't really share sessions between PHP and Java because,


  1. 他们在不同的进程中运行,也许不同的机器上。没有共享内存。

  2. 会话数据结构是完全不同的。

  3. 序列化是不兼容的。

  4. 不同的cookie的味道,PHPSESSID与JSESSIONID。

您pretty多得自己做会话管理共享会话。这是pretty复杂。以下是你写的组件,

You pretty much have to do session management yourself to share sessions. It's pretty complicated. Following are the components you have to write,


  1. 设置一个共同的会话存储,如DB或memcached的。会话存储为大斑点。

  2. 设计一个共同的会话数据结构。我只是用名值对。相同的名称必须在两个系统中使用,并且值必须是字符串(UTF-8)。

  3. 使用一个共同的序列化。我会去用PHP的session_en code(),这是很容易处理了Java。

  4. 处理自己的会话cookie。

这篇关于如何通过Tomcat和PHP之间的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆