CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2007
    Posts
    2

    Exclamation regarding sessions in PHP(its very urgent please)

    Dear sir,

    I have created a chat application using PHP,Javascript and MySQL which is embedded in my web site. I have created a link to go from that website to chat application in the same browser. I have used a window.open to open a new window for chat application which will show you which users are online. Everytime when i click a user in the list a new window gets opened but the session used for both the windows is the same. I have taken that user's id from $user=$_GET['q]; where q is the userid. and stored the value of user in a session called $_SESSION[user_id]=$user; everytime when it opens a new window. The problem is that i need different session for different windows opened. Could anyone please help me. Its very urgent.

    Mandar Chalke

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: regarding sessions in PHP(its very urgent please)

    Well, you can use a random script. The chances of repeat are very slim. But you should have a table for IDs in use and then check the database for IDs in use.

    PHP Code:
    <?php
    if(@$_COOKIE['session_name'] == ""){
      
    $sesid 'session_name' mt_rand(09999999);
      
    setcookie("session_name"$sesid);
    }
    else{
    $sesid $_COOKIE['session_name'];}
    session_id($sesid);
    session_start();
    ?>
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured