- 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?
- How to display images randomly using php?

- 6,703
- 6
- 37
- 58

- 11
- 2
-
4We don't write code for you here; try to write the code and come back when you have specific problems. – christopher Apr 07 '13 at 18:09
-
I don't need the code I just need the hint – Vegeta Kaka Apr 07 '13 at 18:10
-
hint: write some code and we'll fix your code – Ejaz Apr 07 '13 at 18:12
3 Answers
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
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
}
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 ;)

- 3
- 2