-4
  1. Suppose there are 10 users logged into a social networking site and each person have session,How to destroy the session of one particular user?
  2. How to display images randomly using php?
PurkkaKoodari
  • 6,703
  • 6
  • 37
  • 58

3 Answers3

0

Please, search the site or just google around before asking questions. You are warned when asking a question, even a search field is provided. We are here to help not do it for you.
Your questions have been asked and answered before. This is pretty close to what are you looking for - Kill Active Session if User Is Banned

And this is exactly what are you looking for (just replace phrases with image links) - Get random phrases php

Community
  • 1
  • 1
Pankucins
  • 1,690
  • 1
  • 16
  • 25
0

Q1)I don't understand this.

Q2)Just use rand(,) to random the number, and display the different image with the different number. For an example:

<?php
$num = rand(1,3);
if($num == 1){
    ?>
    <---PIC--->
    <?php
}else if($num == 2){
    ?>
    <---PIC--->
    <?php
}else if($num == 3){
    ?>
    <---PIC--->
    <?php
}
0

Q1: I'm not very sure... but if you don't have the session id for the session you want to destroy there's not a sane, clean, portable way to do this. But if you have the session id for the session you want to destroy, you can pass it to the session_start() to resume that session, destroy it, then call your session_start() again to create a new session if it's needed.

Q2: Call your image sources with a number... for example img_1.jpg , img_n.jpg and then with PHP use a rand function to call your images like $img = ran(1,n); print 'img_'.$img.'.jpg' in your img tag. It's not a cleaner solution but you need to thing more deeply ;)