473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to end up session

exoskeleton
104 100+
hi there im about to code for a log-out and i try to code this session_destroy();
but it wont work...the value of the variable stl there.

please tell me sir expert on how to design a log out and how to design a no-cache to prevent the user to click back button of the IE going to log in page again after he log in..

thank you please help
Oct 4 '06 #1
5 11740
exoskeleton
104 100+
in addtion : i got this message if i write session_destroy

Warning: Trying to destroy uninitialized session

hi there im about to code for a log-out and i try to code this session_destroy();
but it wont work...the value of the variable stl there.

please tell me sir expert on how to design a log out and how to design a no-cache to prevent the user to click back button of the IE going to log in page again after he log in..

thank you please help
Oct 4 '06 #2
ronverdonk
4,258 Expert 4TB
If you want to destroy the variable in the $_SESSION use
Expand|Select|Wrap|Line Numbers
  1. unset($_SESSION['var_name']);
If you want to destroy the entire session, use this code snippet from the PHP documentation http://nl3.php.net/manual/nl/functio...on-destroy.php
[PHP]<?php
// Initialize the session.
// If you are using session_name("something"), don't forget it now!
session_start();

// Unset all of the session variables.
$_SESSION = array();

// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}

// Finally, destroy the session.
session_destroy();
?> [/PHP]

Ronald :cool:
Oct 4 '06 #3
exoskeleton
104 100+
thank you sir...im very thankful for your brillian ideas...one more thing sir...ahmmm...if i declare the session is it automatic to create a cookie? coz in your sample given you also unset the cookie but i did not declare any cookie..

i know this is a newbie question ... hope you dont get ... you know.. im just a little confused little fellow coz i dont declare any cookie...

more power

If you want to destroy the variable in the $_SESSION use
Expand|Select|Wrap|Line Numbers
  1. unset($_SESSION['var_name']);
If you want to destroy the entire session, use this code snippet from the PHP documentation http://nl3.php.net/manual/nl/functio...on-destroy.php
[PHP]<?php
// Initialize the session.
// If you are using session_name("something"), don't forget it now!
session_start();

// Unset all of the session variables.
$_SESSION = array();

// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}

// Finally, destroy the session.
session_destroy();
?> [/PHP]

Ronald :cool:
Oct 5 '06 #4
ronverdonk
4,258 Expert 4TB
The code I posted is copied from the PHP documentation and serves as a sample. As you can see the code line
[PHP]if (isset($_COOKIE[session_name()])) {[/PHP]
will only delete the cookie if it is set. You can take that code line out or leave it just in case you ever decide to set session cookies.

Ronald :cool:
Oct 5 '06 #5
exoskeleton
104 100+
Thank you very much sir

The code I posted is copied from the PHP documentation and serves as a sample. As you can see the code line
[PHP]if (isset($_COOKIE[session_name()])) {[/PHP]
will only delete the cookie if it is set. You can take that code line out or leave it just in case you ever decide to set session cookies.

Ronald :cool:
Oct 13 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Damien | last post by:
Hi to all, I'm currently re-designing our intranet : nice and lean CSS2, cleaned-up PHP 4.3.7, better-normalized MySQL ;o). So I've started using the $_SESSION variable instead of register_globals...
1
by: mudge | last post by:
I'm running PHP Version 4.3.10. I'm trying to make it so that when a person logs in using a user name and password that their session is valid and continues for a few months so they don't have to...
6
by: Al Jones | last post by:
This is a repost form the vbscript newgroup - if this isn't the appropriate group would you point me toward one that is. Basically, I seem to be losing session data part way though preparing an...
5
by: Abhilash.k.m | last post by:
This is regarding the session management using Out of proc session management(SQL SERVER). Among the samples below which one is better to set the session? 1. There are 20 session...
0
by: joseph conrad | last post by:
Hi, I tried to implement my own session handler in order to keep control on the process the drawback I foun it is not creating and storing in my cookie the PHPSESSID variable anymore. reading te...
14
by: aroraamit81 | last post by:
Hi, I am facing a trouble. I have some Session variables in my code and somehow my session variables are getting mixed up with other users. For example User A has access to 10 companies and...
7
by: aroraamit81 | last post by:
Well Guys, Here is a very strange trouble. When more than one users request tto same page at the same time then our session gets conflicted. Moreover I printed my SessionID, strangely but true I...
0
by: TRB_NV | last post by:
I'd been using an Access database based shopping cart, but wanted to change it so that it would use session variables. I have a form that's submitted to a page called addtocart.asp that contains...
1
by: Santosh | last post by:
Dear All i am writting a code sending mail with attachement. i am writting code for sending mail in one page and code for attaching a file in the next page. aftet attaching a file i am taking...
5
by: lyealain | last post by:
<% If Session("username") = "" Then Response.Redirect("/CLS/Login.asp") End If Dim conn Dim connectstr Dim db_name, db_username, db_userpassword Dim db_server Dim res
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.