How Can I Send a cookie to Client, but client none request.
Moderator: General Moderators
How Can I Send a cookie to Client, but client none request.
hi all,
there is a problem that I can't see. I am writing a dynamic page use PHP, I want to send a cookie to client and at this time the client don't request, ex.
the client A have connected to Server S1, Now Client B connect to S1, And Client B send a message to S1, Now I want to implement that S1 can notify Client A a information that client B join in on S1's own initiative.
Is this possible? Thanks .
there is a problem that I can't see. I am writing a dynamic page use PHP, I want to send a cookie to client and at this time the client don't request, ex.
the client A have connected to Server S1, Now Client B connect to S1, And Client B send a message to S1, Now I want to implement that S1 can notify Client A a information that client B join in on S1's own initiative.
Is this possible? Thanks .
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
I'm not sure I understand what you're asking. You can't send a cookie unless someone goes to your website and you can't have a cookie do anything other than store information which you can retrieve on the person's next visit to your site. Users can also stop cookies from being set so it's never good to rely on them for anything non-trivial. That said I don't think what you are asking here needs cookies involved at all.
What exactly are you trying to do? When you say "Client B send a message to S1" do you mean through a webpage form? If so then when the form is submitted you can have a bit of scripting that notifies Client A through e-mail.
Really to be of much help I think we need a bit more information.
Mac
What exactly are you trying to do? When you say "Client B send a message to S1" do you mean through a webpage form? If so then when the form is submitted you can have a bit of scripting that notifies Client A through e-mail.
Really to be of much help I think we need a bit more information.
Mac
Sorry , My En is poor. But I mean is....
I want to notify the client A when Client B connect to Server S1, It's must be real time, online, then Email isn't a good solution. i.e. , A and B is online, B connect to Server S1 that may be tell Server by FORM and otherwise. A has none request, Now can the server send a cookie to client A ?
The Server can easy send a cookie to a Client When then client access the server. But now the Client is online , It visited the server a moment ago, and the session not broken; at this time the Client B visit the same server, now i need the server can send a cookie to Client A.
Thank U..
The Server can easy send a cookie to a Client When then client access the server. But now the Client is online , It visited the server a moment ago, and the session not broken; at this time the Client B visit the same server, now i need the server can send a cookie to Client A.
Thank U..
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Maybe I should say this:
<b>If the Client A stay in website persist</b> , and this time Client B conncect to server (server knows ), Now function SetCookie can send a cookie to Client B, But How can I send a cookie to Client A at this time? Maybe this process wouldn't implement, But i want to get the answer.
[/i]
[/i]
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
To set a cookie on Client A's computer when Client B is on the website you need:
If you are looking for a way of having storing the fact that Client B's on-line, mark him active in a database or text file something that your server can access that is independent of Client A or B.
Mac
- To be able to log Client B's existance to a file or database,
- Have Client A still on your website and active (going to new pages, refreshing pages),
- Be able to identify Client A,
- Have script included on every page that checks if the computer is Client A's and if it is whether or not Client B is online and set the cookie if he is.
If you are looking for a way of having storing the fact that Client B's on-line, mark him active in a database or text file something that your server can access that is independent of Client A or B.
Mac
-
NikolasTSR
- Forum Newbie
- Posts: 3
- Joined: Mon Sep 16, 2002 3:07 pm
Hi darnis
1. "to set a cookie" you must sent the information before any other information (html or php code). Witch means that to make "A" aware of "B", "A" must reload his page, or you must refresh it.
2. Refreshing a users page enery now is not a good idea. The never come back.
3. You can use frames and refresh a piece of users page. (I just came up with this, I haven't tried yet)
4. As others allready said, with cookies you only store info to someones computer for a given time. So if you set a cookie on "A"'s computer that "A" is loged in, how can "B" get this info??
5. use an "active user" table istead. Have your users login and isert them to the table. If you refresh the frame (I said before) every now end then you can print there the contents of the "active table". All the users logged in will know how else is logged in.
6. you have to find a way to delete them from the table when the leave your site. You can make them click a "log off" button but what if someone "is on a hurry" and just close the window? Here you must use cookies.
I hope this will help you, if you haven't found an other way allready.
1. "to set a cookie" you must sent the information before any other information (html or php code). Witch means that to make "A" aware of "B", "A" must reload his page, or you must refresh it.
2. Refreshing a users page enery now is not a good idea. The never come back.
3. You can use frames and refresh a piece of users page. (I just came up with this, I haven't tried yet)
4. As others allready said, with cookies you only store info to someones computer for a given time. So if you set a cookie on "A"'s computer that "A" is loged in, how can "B" get this info??
5. use an "active user" table istead. Have your users login and isert them to the table. If you refresh the frame (I said before) every now end then you can print there the contents of the "active table". All the users logged in will know how else is logged in.
6. you have to find a way to delete them from the table when the leave your site. You can make them click a "log off" button but what if someone "is on a hurry" and just close the window? Here you must use cookies.
I hope this will help you, if you haven't found an other way allready.