Session Id In A Long Life Cookie
Okay, my session's cookie is by default set to destroy on session closure. I want to make this cookie last 30 days. the only way I came up with is to put:
session_set_cookie_params()
before every time I say session_start(). Is there an easier way to do this? something that I can do only once?
View Complete Forum Thread with Replies
Related Forum Messages:
How Long Can I Make A Cookie Last?
I realize that the "cookie" is not a PHP-specific topic. However, I'm developing my web site using primarily the PHP programming language so I thought that the PHP forum would be an appropriate place to post this question. My question is this: Is there a limit on the amount of time that a cookie will remain on a user's computer? In other words, if I code a time frame of a year or two for the cookie to expire will the cookie stay on the user's computer for that long?
View Replies !
How Long For A Session?
how long a session lasts for. It's been a long time but I thought it was 20 minutes by default. IS this correct or is it some other time? Assuming the browser is not closed of course.
View Replies !
How Long To Session Vars Last?
How long do session vars last? I believe some of my applicants are taking a long amount of time to complete their app, which is creating problems. Is there a way to lengthen the time that a session var is available? I would also like to do this to allow admin/csr's to stay logged in longer without having to log back in.
View Replies !
How Long Does It Take For A Session To Timeout
How long does it take for a session to timeout,if I have a user logged in on my site, how much time of inactivity will it take before the session is automatically destroyed and they become logged out,i do not use cookies,I have these values in my php info session.cache_expire 180 session.gc_maxlifetime 1440 session.gc_probability 1 from what I understand the session is destroyed after 180 minutes of inactivity,but the session has a 1% chance of being garbage collected after 1440 seconds of inactivity (is this destroyed?) so if I wanted all sessions destroyed after the 1440 seconds, should i set the probability to 100 or should i change the session.cache_expire 180 to something that would suit me better, i.e. the 1440 seconds, i.e. session.cache_expire 24, would this always delete the session after 24 minutes,or do both values have to correspond etc,
View Replies !
Long Post About PHPEclipse Session Debugging
debugging PHP applications interactively is possible, easy and free. I am talking about PHPEclipse and using it for debugging over several scripts or debugging through a session. Since I have wasted a lot of time writing echo statements all over the code in order to confirm program flow and watch variables, I feel I must share this with others who will be facing similar problems. PHPEclispe users can go to Step 5 directly. (People who already have software which does all this or feel that their software is the best suited, please ignore this post :-)) 1) First you need to get PHP and Apache. (My OS is Windows XP Pro.) The best choice IMHO is XAMPP, as it allows you to do many things - my version is 1.4.15 and it has, apart from Apache2.0.54 and PHP5.0.4, phpMyAdmin2.6.3, FileZilla FTP, Webalizer and many more things. It also allows you to switch between PHP4 and PHP5! So, get XAMPP at http://apachefriends.org. 2) Second, you need to get PHPEclipse. For that you need Eclipse first. Eclipse can be got from http://eclipse.org. There are two releases of Eclipse - Eclipse 3.0 and Eclipse 3.1 (although I use 3.0, it seems 3.1 is the better one - also, there are other free products like JSEclipse which need 3.1 - sooner or later you will need Javascript in your PHP application, for that, you need Eclipse 3.1) Installing Eclipse 3.0 on windows was as simple as unpacking the zip into a folder, say c:eclipse and double-clicking on eclipse.exe to start. I've not tried 3.1 but I believe the installation should not be any more difficult. ********** Before downloading anything first read up the PHPEClipse related wiki page at http://www.plog4u.org/index.php/Using_PHPEclipse ********** Also read up http://www.plog4u.org/index.php/PHPEclipse_FAQ NOTE: PHPEclipse runs from within Eclipse as module ("plugin"). 3) After you install Eclipse and PHPEclipse, comes the important part. I'm just writing the steps which confuse most - since you have all the necessary help needed available at http://www.plog4u.org/index.php/Using_PHPEclipse in detail. Assuming you have PHP files ready which you want to debug, you need to create a new project in PHPEclipse. Go to Window->Show View->Navigator. This shows the navigator pane. Now right-click to get a pop up menu which gives among other options New->Project. Click that and choose PHP->PHP Project in the next form in the wizard. Click Next to get the New Project (PHP Project) form. There you have a place to give your project a name and a place to specify the folder (you will miss this one if you do not look closely as you need to uncheck a checkbox labelled "Use default"). Now specify the folder location in the folder selection box. This step troubled me for quite some time. 5) Follow http://www.plog4u.org/index.php/Using_PHPEclipse for intermediate steps like getting and installing the DBG debugger 6) For debugging, you start by first setting up the environment by setting paths and options in PHPEclipse. Click on Run menu in Eclipse, then "Debug ..." (Debug dot dot dot). A window appears with a navigator/explorer pane on the left and many tabs on the right. Give a name (anything) to the debug configuration. Enter the paths in the File tab and the Envirnment tab. Environment has two sub-tabs - Remote Debug and Interpreter. In Remote Debug, check the Remote Debug checkbox and (MOST IMPORTANT) uncheck the "Open DBGSESSION url in internal browser" checkbox. This is needed, we will soon see why. Also, set the Remote SourcePath to be a part of the full path to your php script. The rule about the RemoteSourcePath is that (RemoteSourcePath in the Environment tab) + (File path in the File tab) = actual full path to your php file. On the Interpreter sub-tab, if you have set things up correctly (with XAMPP) you should see a php and a php5 option. Choose either. If nothing is shown, you can add an interprter by setting a name for it and the path for it from the adjoining "New..." button. Try a few things and you should be able to start a debug session in about an hour if not in a few minutes. 7) Finally, run the Debug configuration (i.e., start the debugger) It will now switch the window layout and show an active red button in the debug toolbar with a few debug details in a prominent debug pane. It is now _waiting_ for a request from any browser application. Set a breakpoint in your PHP code (double clicking on the thin margin at the left of the source code window, next to the text area). Also, set a breakpoint in the next file that will get called when the user performs a form submission in you first page. Now, open your favorite webbrowser (independent of PHPEclipse) and enter the url : http://localhost/myproject/myfile.p...localhost:10001 or http://localhost/myproject/myfile.p...lienthost:10003 One of these should work. A moment or two after you enter this (PHPEclipse must be in the waiting-to-debug mode) you will see control switching to PHPEClipse and the line in your first page where you set a breakpoint will get highlighted by the debugger. Step through to the end. and switch back to your web browser (where page two is now being displayed). Click on a form submit and see how control switches back to PHPEclipse on the line in the second page where you had put a breakpoint. Thus you continually switch between your web browser and PHPEclipse. The process can go on to as many number of files as you wish - just set breakpoints in all the files before starting debugging. Trust me, it is a good alternative to writing echo statements all over the place to trap errors in a 15-20 page PHP application. NOTE: On Windows, when control is switched to PHPEclipse, the Windows taskbar button for PHPEclipse blinks, indicating that that program demands interaction. I dont know how it is on Linux. The important thing is to not start the debugger in the internal browser. For that you must uncheck the checkbox saying "Open DBGSESSION url in internal browser" which can be found in Run->"Debug..."->Environment tab->Remote Debug tab. Somehow, (on my machine at least) the internal browser does not support debuging over multiple pages. Hope this helps someone, because I've wasted a lot of time adding echo's and exits to see the state of variables in various places in my scripts and it is quite tedious. That kind of debugging has its merits, though - you become really well versed with your code!
View Replies !
Warning: Session_start() [function.session-start]: Cannot Send Session Cookie
I've wrote a login script thats self contained, in other words all the checking etc.. is contained in the same file, i.e password checking etc... I keep getting the following error... Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at d:inetpubwwwrootac-kreationsadminauthadmin.php:1) in d:inetpubwwwrootac-kreationsadminauthadmin.php on line 4 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at d:inetpubwwwrootac-kreationsadminauthadmin.php:1) in d:inetpubwwwrootac-kreationsadminauthadmin.php on line 4 Here's the start of the code. PHP Code:
View Replies !
Warning: Session_start(): Cannot Send Session Cookie - Verify That The Current Setting Of Session.save_path Is Correct
Warning: session_start(): open(/tmpsess_526e492c7e6fbe4887e4c52821b34be7, O_RDWR) failed: No such file or directory (2) in C:Program FilesApache GroupApache2htdocsTempMgtindex.php on line 15 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:Program FilesApache GroupApache2htdocsTempMgtindex.php:15) in C:Program FilesApache GroupApache2htdocsTempMgtindex.php on line 15 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:Program FilesApache GroupApache2htdocsTempMgtindex.php:15) in C:Program FilesApache GroupApache2htdocsTempMgtindex.php on line 15 Warning: Unknown(): open(/tmpsess_526e492c7e6fbe4887e4c52821b34be7, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
View Replies !
PDO Transactions Life Span
Do transactions automatically commit or rollback after a specific period of time? does mySQL close its connection after a specific time? or maybe PHP closes the connection? I've got quite a semi-complicated script that takes about 85 seconds to execute usually. This is due to it accessing remote files etc as that just adds time. Code:
View Replies !
How Long Is Too Long For A Script To Execute? GetTimer()
I'm using some scripts and they're executing from .007 - .010 It defines many files, imports several files (total of maybe 20), encrypts 2 strings several times base64 IN flash, WWW-Authenticating to a PHP file, PHP grabs a MySQL Query, returns it, traces it. That happens all in .007 seconds roughly. How long is too long until you should find a new script. If a script runs with a time of .05, is that the general limit or is that fast?
View Replies !
Real Life Examples Of Mysql+session_set_save_handler
In my test setup using my own session handlers with session_set_save_handler and mysql, the session handler opens and close mysql connections. But what if my page also requires some mysql queries? Should I open a new connection or use the already opened one (opened by the session handler)? I have made it a good practice to close a connection after a query but if I do it with only connection open no session data will be written to my mysql table. I have seen some scripts using persistent connections but are not sure what would be the best for a real world environment.
View Replies !
Session Cookie
What happens when the the previous session cookie is not destroyed (but session_destroy() and session_unset() have been used previously) apart from the fact that the previous session id will be used. Does this mean that the previous session only will continue? Could this cause problems while logging in (assuming only the session id is stored in the cookie and all the session variables are set again on the checklogin page)?
View Replies !
Session / Cookie
I have the following fragment of code that i can not get working as expected. Essentially, its for persistant sessions. A cookie is put on a users pc with some other info and it keeps you logged in. Sessions are killed off if the user doesn't login for a long time. This appears to work fine on my test server, and used to work on my old server, but after a server move, it appears to no longer work. I can't fathom why. on_session_write had a problem where it thought the db object no longer existed, so i recreated an object in that function. However, the data is now not read from the database, so even though i successfully login, when i click through to another page on my site it logs me back out again. Code:
View Replies !
PHP Session Cookie In IE7
I am having a bit of an issue working with a PHP session in IE7. I'm just starting to set this up, so for informational purposes, all I have is a page that starts a session and then displays the SID. Now in Firefox, I start a session and it places a session cookie on my system. If I kept refreshing this page, the cookie still exists and thus the session, so it keeps displaying the same SID. Now if I deleted the cookie, a new session would be created on my next refresh with a new SID and cookie. In IE7, I cannot find the cookie for the session. I checked using Nirsoft Cookie Viewer as well as looking myself in Windows Explorer. There is no cookie. However, when I refresh the page, the SID stays the same, as if the session is active and the cookie does exist. Perhaps it does and I just don't know where. Any ideas? Also, in regards to sessions, I was under the impression they had a default lifetime of 3 hours. However, I have left my computer for far longer than this, and when I return, it is still active. Does it only end when the browser is closed?
View Replies !
Session Without Cookie
I'm trying to enable the session management without using cookie. In my php.ini I have: session.use_cookies = 1 session.use_only_cookies = 0 session.use_trans_sid = 1 session.name = PHPSESSID I call session_start() on each page. I turn off the cookies in my browser and browse my site. The session doesn't work and no "PHPSESSID" appears in any URL.
View Replies !
SESSION Instead Of The COOKIE
Working on a shopping cart for a buddy, and currently, I assign a unique# and store it in a cookie, if a cookie doesn't exist already. Then that # is used to keep track of the user's shopping cart items. Basic stuff. Currently I have it set so when you click on 'add to cart' it pulls your # from your cookie, but I was wondering if it's better/faster/more proper to get/set the cookie #, then store it in a SESSION var. and use/pull from the SESSION instead of the COOKIE all the time (after that initial visit)?
View Replies !
Cookie Or Session
I am trying to use curl to logon to a site and have been doing sum reading on it, i have read sumwhere that u need to find out whether or not the webserver is using cookies or sessions to validate you login. How would i find this info out?
View Replies !
Session Vs. Cookie
session id is a cookie. I am using session to save the information about a shopping cart. and in every page, i will display how many items in the shopping cart. I want this value to be updated as I add or remove items from the cart. I can use session value or cookie here. session_start() will expire the page? so if i use the session, next time i visit this page, due to the page expired, it will display the new value. But if i use cookie, if i don't expire that page using header, then i may get old cookie value displayed when next time i revisit this page.
View Replies !
Strtotime And Dates Long Long Ago ...
while making an encyclopdie on my hometown (dutch, http://www.kgv.nl/index.php?id=610) i am trying to use dates prior to 1970. birthdates in, let's say, 1615. i'm getting errors while working with these dates, for example when i am calculating which day of the week it is. the dates are stored in a mysql database. is there another way to convert stringtype dates to work with?
View Replies !
Session Cookie Error
I've been testing using session and it worked fine on my local machine, but when i put it on a distant server i get this error: Cannot send session cookie - headers already sent by (output started at /home/www/sites/arcadtest/admin.php:10) I also get an error each time i use header to redirect ...
View Replies !
Php Session Without Cookie Useage
I need some clarification on how the php session work in relation to cookies. we have a web site where users need to log in. a few of our users were having troubles with their browser clients having different levels of cookie security settings. i assumed a solution would be to have the php site use the session only, and set session.use_cookies to 0 in the php.ini file. after doing this, the session no longer persits after moving from page to page. does the session need to have cookies enabled to work? if so, what is the point of this setting? if not, what settings do i need to set to make the session work sever side only?
View Replies !
Object As Session/cookie
how is your experience with using objects as sessions??? This is for a project at uni, so I need some input on the good/bad things with doing it this way. Personally I think it is nice working with a object, quicker coding, and much cleaner than writing normal sessions w/variables. Also: I'm making a different asignment where a glossary db can be signed by students for later retrival when they look up a word. (each student can see what he/she wrote earlier on on that word). I'm not going into that, but I'm going to send back to the Flash movie an indication if the student currently logged in has signed a term in the glossary, so: instead of doing a query each time the user retrieves something from the server, would a quick search in MySQL when the user logges in, and then store the ID of all the terms he/she has commented in a object session/cookie. Then use the information in the session/cookie to send back indication to the Flash movie be better?
View Replies !
Session Or Cookie With Mysql
I have a rating script which does everything i want of it apart from track the user to see if they have rated an item more then once - as they can rate over and over again how would i add say a session control or set a cookie so the script knows its the same person from say that ip?
View Replies !
Delete Session Cookie
I need to delete the cookie that a session sets. I know there is an option in php.ini to make a session not set a cookie, but I do not have access to the config files. Anyone know how to do this?
View Replies !
Session Id Is Determined By The Cookie?
When we open a new web browser, all the windows that are open from that web browser belong to the same session. However, if we open a new web browser, then it will be different sessions. Is that the correct concept? Another question is if session id is generated by the web server? Session ID is determined by the cookies? Otherwise, how can the web server know this is new session, or old session?
View Replies !
Use A Cookie To Keep Track Of The Session?
I have this little test application I made (see code below). I have looked for a cookie that keeps track of the session but I cannot find one does PHP use a cookie to keep track of the session? First file test.php //*********** Start Here <?php session_start(); header("Cache-control: private"); // IE 6 Fix. ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <FORM METHOD="POST" ACTION="test2.php"> Enter your Name: <input type="text" name="name"> <input type="SUBMIT" value="Submit"> </FORM> </body> </html> Second file test2.php //*********** Start Here <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php // start the session session_start(); //header("Cache-control: private"); //IE 6 Fix // Get the user's input from the form $name = $_POST['name']; // Register session key with the value $_SESSION['name'] = $name; // Display the sssion information: ?> Welcome to my website <strong><? echo $_SESSION['name']; ?></strong>!<br /> Let's see what happens on the <a href="test3.php">next page.</a><br /><br /> </body> </html> Third file test3.php //*********** Start Here <?php // start the session session_start(); ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> Welcome to my website <strong><?php echo $_SESSION['name']; ?></strong> </body> </html>
View Replies !
Session Cookie Problem
I have sessions finally working, except for one glitch. after a session is started, the session variables are set to values from a form, then on a final page, inserted into a mySQL table. THen the session variables are unset, and the session is destroyed. this all seems to work, EXCEPT if you try to go through the submittal process again, it inserts all NULL values into the table, even though if you try to output the session values before inserting them, it seems to do that. if you close all the browser windows, and then go back to the page, it works just fine again. obviously, it can't work like that. here is the code on the page that gathers the info from the form (note, there are two forms, and the page sends data to itsself at least once): if(!isset($PHPSESSID)) { session_start(); session_register("SESSION"); } else { session_id($PHPSESSID); session_start(); } and this is the code at the end of the page that inserts the data into a table, and destroys the session and session variables:(the top of the page checks for a session and loads the registered variable in the same way shown above) session_unregister("SESSION"); session_destroy($PHPSESSID); again, the first time through, it works perfectly, and it seems to destroy the session info correctly. however, if you try again, everythign works fine until you insert the data, and at that point it inserts all NULL values into the table. in order to get it to work again, you have to close all the browser windows and then start again. it's apparently a session cookie problem, but i'm not sure where the problem is (and yes the session ID is propegated).
View Replies !
Session Cookie/browser
I have a problem with sessions and the session data not being lost when the browser is closed like it should do (and is set to do). It worked 2 weeks ago, and I'm assured the server has not been touched for at least a month. Code:
View Replies !
Session Cookie NOT Required
I am finding that PHP automatically sends out a session cookie, even when I dont want it to. I have a hitcounter that is a single file. When called, it automatically sends a session cookie which is blocked by IE6 as a 3rd party cookie. As it is a single file call, there is no session, I really would rather not be sending a cookie. Is there any way to stop this? I have also put up a /wc3 folder with a p3p policy in it - but to no avail. 3rd party cookie is still blocked.
View Replies !
How To Set A Session Cookie With A Path?
I need to set a session cookie (expires when the browser closes) with a path of "/". Is there a way to do it? I tried: setcookie("cookie_name", $cookie_value, "", "/"); and setcookie("cookie_name", $cookie_value, "0", "/"); and of course none of them worked. I can't move the page that is setting the cookie to the top level directory of the site, but I need the cookie to be available to couple of page there.
View Replies !
Cookie Session Script
I have a Post script in another login screen that passes a password variable and with action 'Login' that feeds a protection.php script. It seems that my script correctly validates the login, but it does not read the cookie to see if the session is still active. Here is the contects of the protection.php script: Code:
View Replies !
Session Cookie Persisting
I'm trying to recreate my RFDMaker in PHP. I've decided to do it in a series of steps, using sessions. With cookies turned off it works fine (I've only done the first three steps). The session ID is passed in the url so the user can go forwards and backwards. However, with cookies on, the session persists even if I close the browser. I thought that, unless specified otherwise, cookies only persisted while the browser was open. Am I missing something or is it my machine/setup? Could someone test it for me?
View Replies !
Cannot Send Session Cookie
I am trying to create a user system for my website, when I log in I get these errors: Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:documents and ....
View Replies !
Cookie/Session Security
I'm currently working on a site that uses SSL on another server. As a result i'm unable to transfer the session over in a normal way. Having read a bit on this subject, it seems i'll store the session's id into a database, along with the username. After the user logs in, this sid is stored, and then a cookie will be set(with the encrypted sid in the cookie and on the database). Now when the user goes to the main site, it will check that they have the cookie, and then print a welcome message as well as some other custom info. All in all, how secure of a method is this? If you set a cookie with an encrypted value to expire after a given time, I suspect it would be unlikely (albeit possible) someone could generate a random value and try to log in with it (maybe have a script run all day to attempt this).
View Replies !
Ask Cookies N Session.cookie
1. how many ways or function could we use to create cookies? 2. what are the different between setcookies and session.use.cookies? are they have same use...? 3. setcookies has its lifetime (in the declaration/use) hasn't it ? so why there is a session.cookie_lifetime function?
View Replies !
Delete Session And Cookie
I have the following code: if($_GET['logout'] == "true") { session_start(); unset($_SESSION['the_ID']); session_unset(); session_destroy(); unset($_COOKIE['domainp']); } But, when I execute the code don't kill the session and don't remove the cookie... Why?
View Replies !
Session Cookie Problems
I have a website that authenticates users and then allows them to visit member only parts of the site. The authentication uses cookies. When the user has logged in and the script has satisfied itself that the username and password are correct (comparing against a MySQL table), the following session script is run: Code:
View Replies !
Session Data - Do I Need To Set A Cookie?
I've got this checklogin.php script (below). It uses a session with no cookies. And was wondering what the best way to access this data, from other pages, would be? As once the user has logged in, I would like to display their username on all other pages. Do I need to set a cookie? Is there a way I can do it without a cookie? Script: PHP Code: $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="acm_members"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $myusername=htmlentities($_POST['myusername']); .................
View Replies !
Set Cookie/session Via Ajax
I have not tried this yet but was wondering if you can set/create session/cookies vars from a php script being called with ajax? I am guessing no since that page is already loaded but since ajax calls a php script that works in the backend maybe it has its own environment and can do that?
View Replies !
|