Question about The PHP Group PHP

2 Answers

Logout script with session management in php5

I failed to script a logout web page in php with session management.my script doesn`t get any affect by logging out when the BACK button is pressed.can u help me

Posted by on

  • fetusbata May 11, 2010

    hi, can you give me the code that you made?
    I'll suggest to use cookies because cookies are suited for logging out implementation. As what i have read, session is use for passing the data to another page.

×

2 Answers

  • Level 1:

    An expert who has achieved level 1.

    Corporal:

    An expert that hasĀ over 10 points.

    Mayor:

    An expert whose answer gotĀ voted for 2 times.

    Problem Solver:

    An expert who has answered 5 questions.

  • Contributor
  • 15 Answers

Just create a logout.php script with the following

<?php
session_start();
session_destroy();

header("Location: index.php");
?>

Have your logout button/link/whatever just open that page which connects to the session with session_start. Session destroy does exactly what it sounds like... it unsets all session data and tells the server to end the session. The header request then just re-directs the user to whatever page you want after (just change out index.php)

Posted on Mar 17, 2009

  • djroot2 Mar 17, 2009

    I should have added the following between the session_start() and session_destroy() as session_destroy doesn't actually unset the variables and won't delete any cookies set.

    $_SESSION = array();

    if (isset($_COOKIE[session_name()])) {
    setcookie(session_name(), '', time()-42000, '/');
    }


×

  • Level 1:

    An expert who has achieved level 1.

  • Contributor
  • 3 Answers

If it doesnt take effect its probably not actualy exicuting your logout script right.

the main part would be that it does this... (eg. level session)
unset($_SESSION['level']);

as soon as thats happend the session should be gone

oo and its worth double looking out for having ..
session_start();
.. in there,
little line im always forgetting yet its so important

Posted on Feb 06, 2009

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
goodluck!

Posted on Jan 02, 2017

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

4 Answers

What is java script


Java script is a program that works with other programs such as Adobe Flash Player and many others to procees and enable you to read and store items. You can get Java here;
http://www.java.com/en/
If you were trying to watch YouTube you would have to have Java and a Flash Player in order for your system to process and play the video. I f you need Flash Player you can get that here;
http://get.adobe.com/flashplayer/
You have to make sure you have no prior versions of either of these products so, check in device manager and make sure you don't have prior versions. If you do, unistall the prior versions before download od new versions.

May 10, 2011 | Sun Computers & Internet

1 Answer

Please i want php script for image uploading in to wordpress upload folder


when you add a page or post from wordpress admin you get a image icon above the description textarea box to add images to the wordpress site

Other way is there is media manager in wordpress admin where you can upload images through that and make the gallery of images

Mar 08, 2010 | The PHP Group PHP

1 Answer

Retrieving and displaying logged in users info


you had not provided complete detail that if you are having database for username or you want to fetch username from 'email providing site' in which your user created his account.if you are trying for second option,It is almost not possible coz any of the email providing site will not exchange personal detail of any of his acc holder.
if you are trying first option,session in php can help you.you can store username in a session variable n then u can access them on any page if session is not destroyed or expired.

Mar 22, 2009 | The PHP Group PHP

1 Answer

Php assigning value to variables and posting result, how can i assign a value to variable that will add the score evertytime the answer in my trivia page is correct, how can i make a formula for total...


You can use a session variable.
First use session_start().
Then you can crate a session variable by simply setting the appropriate member of the $_SESSION or $HTTP_SESSION_VARS (PHP < 4.1.0) array
Example.

session_start();

$_SESSION["number"] = 10 ;

echo $_SESSION["number"];

You can call it whenerver you want.
remmember to start session on all the pages where you use the variable.

Mar 17, 2009 | The PHP Group PHP

1 Answer

Logout problem


Hey,
what code are you using to destroy the session?

should look something like this
e.g. getting rid of email session
<?php
unset($_SESSION['email']);
?>

Jan 16, 2009 | The PHP Group PHP

1 Answer

Clarification


are you saying you're switching from a session variable to a cookie?

delete the cookie altogether by setting the expiration to a time in the past (negative value). don't forget that you'll then have to reload a page in order to reread the cookie data.

so if you have a cookie with a logged_in value = true, and you set it to logged_in value = false, you're still logged_in = true, until you reload that page (or another page) and it rereads the cookie data and now determines that logged_in = false.

make sense? write the logged_in=false to the cookie, then force a url redirection to reload the page is my suggestion.

Jan 13, 2009 | The PHP Group PHP

2 Answers

PHP Source


hi,

i would like to tell that the php code doesn't appear when you open the source of the webpage , the server hides the php codes simply ,

thanks !

Sep 03, 2008 | The PHP Group PHP

1 Answer

PHP Error 500


Internal Server Error 500 is usually caused by either a malformed cgi script or an invalid directive in an .htaccess file located either in the same directory as the page throwing an error, or in any directory above it.

Have you recently uploaded or editted an .htaccess file that includes mod_php related directives such as php_value ..., php_flag ...?

If you did start your search there.

Aug 26, 2008 | The PHP Group PHP

Not finding what you are looking for?
The PHP Group PHP Logo

Related Topics:

1,230 people viewed this question

Ask a Question

Usually answered in minutes!

Top The PHP Group Computers & Internet Experts

Robin Hill
Robin Hill

Level 3 Expert

1251 Answers

Mike

Level 3 Expert

4332 Answers

Mishan Kasiparsad

Level 2 Expert

142 Answers

Are you a The PHP Group Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...