Today we'll write how to use JS to set cookies, read cookies, and delete cookies. This code comes from the Web and is accompanied by a common Web page that uses cookies for learning.
Set cookies
The code is as follows
Copy Code
JSP has a feature that implements a commit with a hyperlink
Html:
Submit
Js:
function Btnsub () {
//logical judgment omitted, the final purpose is to choose the action
document.frmaction.action= "Xxx.action" according to the
The example in this article describes how jquery controls cookie expiration time. Share to everyone for your reference. The specific analysis is as follows:
The Jquery.cookie () method allows you to set cookies, which are invalidated by default
The cookie in the built-in browser is very strange. This is the code for setting and deleting the COOKIE {code ...} in a common browser, there is no problem at all. However, after you open this website, you can log on to the website. However, you cannot exit the website and cannot delete cookies... it's still time-based ,... the cookie in the built-in browser is very strange.
This is the code for setting and deleting cookies.
function set_cookie($var ,$value = '' ,$
Cookies in the built-in browser it's weird.
This is the code to set up and delete cookies
function set_cookie($var ,$value = '' ,$expire = 0){$path = '/';$domain = 'aaa.com';$auth = 'sadfsadfasdf';if($value!='') $value = _myencrypt($value ,$auth);$var = '__abc_'.$var;if($expire==0){ $expire = 0;}else if($expire > 0
head and tail nodes of the linked list, respectively. The node in the list is the item assigned by the Slabclass, the newly assigned item placed on the head, and the more the list is back, indicates that it has not been used for a long time. When Slabclass is out of memory and needs to delete some expired item, it can be deleted from the tail of the list, and yes, the list is for LRU. It doesn't work, because the list of queries is O (n), so when you locate the item, use the hash table, which a
timeout time, the new Key_A inherits all the features of Key_ B.Refreshing expires refresh expiration It is possible to call EXPIRE using as argument a key that already has an existing expire set. In this case the time to live of a key isUpdatedTo the new value. There are too useful applications for this, an example is too ented inNavigation sessionPattern section below.You can use the
Set the data expiration time by expire the key seconds command. A return of 1 indicates that the setting was successful, and returning 0 indicates that the key does not exist or the expiration is not successfully set.After the expiration time is set on the key, the key will be automatically deleted after the specified number of seconds. Keys that have been assigned an expiration time are known to be unstable in Redis.The expiration time associated wit
RENAME command, for example, if a Key_A already exists, run the RENAME Key_ B Key_A command (RENAME key_ B as KEY_A), no matter whether the original Key_A has an association timeout time, the new Key_A inherits all the features of Key_ B.
Refreshing expires refresh expiration It is possible to call EXPIRE using as argument a key that already has an existing expire set. In this case the time to live of a ke
Explore Redis data expiration policies
Use the EXPIRE key seconds command to set the data expiration time. If the return value is 1, the setting is successful. If the return value is 0, the key does not exist or the expiration time cannot be set successfully.
After the expiration time is set on the key, the key will be automatically deleted after the specified number of seconds. Keys with a specified expiration time are called unstable in Redis.
When
simple idea of implementing a distributed lock and task queue, and if you've seen a bit of ambiguity, see the next code implementation.
Third, Code Analysis
(a) first to analyze the Redis distributed lock code implementation
(1) In order to avoid the special cause of the lock can not be released, after the lock succeeds, the lock is given a lifetime (via the Lock method's parameter setting or using the default value), and the lifetime lock is automatically freed by default for a shorter lif
timeout; // timer timeout time, in millisecondsLong expire; // The remaining timeout time of the timer during the next interruption, in millisecondsInt inuse; // whether the timer is usedInt set; // whether the timer times outInt signal; // The type of event sent when the timer times out.Int Param; // the parameter of the event type sent when the timer times out.} T [max_timers]; // timer setThe software timer provides four interfaces for the applica
"); }}/** * constructor. */Private Memcachedutils () {}/** * Adds a new key-value pair to the cache. If the key already exists, the previous value will be replaced. * @param key * @param value * @return Boolean */public static Boolean set (String key, Object value) { Return Setexp (key, value, NULL); }/** * Adds a new key-value pair to the cache. If the key already exists, the previous value will be replaced. * @param key * @param value * @param
/** Cookies class to save, read, update, and erase cookies data. Prefix can be set. Force timeout. The data can be strings, arrays, objects, and so on.
* Date:2013-12-22
* Author:fdipzone
* ver:1.0
* edit:bbs.it-home.org
* Func:
* Public Set Cookie
* Public Get Read Cookie
* Public Update Update Cookie
* Public Clear Clear cookies
* Public setprefix setting prefix
* Public Setexpire Set Expiration time
* Private Authcode encryption/decr
Private $expire; Expiration time, seconds, 1~2592000, i.e. within 30 days; 0 to never expire
Private $sleepTime; Wait for unlock time, microseconds
Private $queueName; Queue name, unique value
Private $retryNum; Number of retries, = 10 * Theoretical concurrency
Const MAXNUM = 2000; Maximum number of queues (single-sided), recommended maximum 10K
Const Head_key = ' _lkkqu
current team.
Private $ currentTail; // Current team end value
Private $ lastHead; // The first value of the previous team.
Private $ lastTail; // The final value of the previous team.
Private $ expire; // expiration time, in seconds, 1 ~ 2592000, that is, within 30 days; 0 is never expired
Private $ sleepTime; // waiting for unlock time, in microseconds
Private $ queueName; // queue name, unique value
Private $ ret
time granularity, and n represents the size of the time wheel, that is, how many buckets a time wheel has. Set U equals 1, equals 3, start time is C. At this point, the buckets at different levels are the following:
* Level Buckets* 1 [c,c] [c+1,c+1] [c+2,c+2]* 2 [c,c+2] [c+3,c+5] [c+6,c+8]* 3 [c,c+8] [c+9,c+17] [c+18,c+26]
Bucket time-out (expire), based on the start time of the bucket. So at c+1 time, [C, C], [C, c+2
implementation of the method declared in the parent class.* @ Param string $ key a unique key identifying the cached value* @ Return string------ Solution ----------------------Boolean the value stored in cache, false if the value is not in the cache or expired.*/Protected function getValue ($ key){Return $ this-> _ cache-> get ($ key );}/*** Retrieves multiple values from cache with the specified keys.* @ Param array $ keys a list of keys identifying the cached values* @ Return array a list of
forcibly converted to int type without any other processing, so it will become-1702967296 and an error will be reported.
But directly under the redis command line will not be negative ,.
But it doesn't matter. it's easy to fix. we can change it to seconds.Open vendor/yiisoft/yii2-redis/Cache. php
The
133
Line, modify to the following code.
Text
Protected function setValue ($ key, $ value, $ expire) {if ($
generates the corresponding content. for (j = 0; J Looking at the dump process for each db is actually traversing and outputting each key-value pair. Redisdb *db = server.db+j; Dict *d = db->dict; if (dictsize (d) = = 0) continue; DI = Dictgetsafeiterator (d); if (!di) { fclose (FP); return redis_err; }First determine if the db is empty, and if it is empty, skip. Then get the iterator for the DB. /* Write the SELECT DB op
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.