douyingp82418 2013-03-07 17:38
浏览 44
已采纳

PHP更改会话cookie文件的内容

I´m not sure If I am making a mountains out of molehills ...

I´ve two Servers A + B. I know on Server A exists a PHP Session with a session cookie. I know further in one of the session files (stored in var/lib/php5) exists a unique value like:

$_SESSION['name'] = "1_colourXY"

I can identify this cookie file with php by searching the dir/ files for this value (f.e.: file sess_489b9515146e7390ac03b5dabf36b70e).

I now want Server B to be able to tell A to store a new value to this explicit cookie file. My solution is:

Server B (which is not the client who has started the session!) calls a PHP file on Server A. After B has passed some security checks A should write a new value to this cookie file with file_puts_content. Note, as written Server B has not started the session so I think I cannot simple do

session_start();
$_SESSION['myval'] = "new val";

Therefore I have following questions:

  1. Is there an easier (native session handling) way instead of file_puts… to write the value to the cookie file something like:

    write $_SESSION['myval'] = "new val" to
    sess_489b9515146e7390ac03b5dabf36b70e
    
  2. The session Dir var/lib/php5 has chmod 773, to write and search within it I have to change rights to 777 (urrgh). How can I keep 773 but make it useable for php

  3. If I open a cookie file a value looks like this: place|s:6:"Muster"; What does |s:6: mean?

Kind regards,

tony

  • 写回答

1条回答 默认 最新

  • duanlinma5885 2013-03-07 17:44
    关注
    1. You should use a DB like MySQL to store your sessions, then abstract all session calls into that database.

    2. see 1.

    3. This is how PHP types are serialized to a string. In this case s:6:"Muster" is a string 6 chars long, which happens to be "Muster".

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch