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. 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".